Skip to content

Commit a1fd7e6

Browse files
committed
log: use sizeof(*hdr) instead of sizeof(hdr)
Using sizeof(hdr) where hdr is a pointer gives the size of the pointer, not the size of the structure it points to. Reported-by: Kir Kolyshkin <[email protected]> Signed-off-by: Andrei Vagin <[email protected]>
1 parent 6799dc7 commit a1fd7e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

criu/log.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void flush_early_log_buffer(int fd)
190190
* with reading the log_level.
191191
*/
192192
struct early_log_hdr *hdr = (void *)early_log_buffer + pos;
193-
pos += sizeof(hdr);
193+
pos += sizeof(*hdr);
194194
if (hdr->level <= current_loglevel) {
195195
size_t size = 0;
196196
while (size < hdr->len) {
@@ -323,15 +323,15 @@ static void early_vprint(const char *format, unsigned int loglevel, va_list para
323323
int log_size = 0, log_space;
324324
struct early_log_hdr *hdr;
325325

326-
if ((early_log_buf_off + sizeof(hdr)) >= EARLY_LOG_BUF_LEN)
326+
if ((early_log_buf_off + sizeof(*hdr)) >= EARLY_LOG_BUF_LEN)
327327
return;
328328

329329
/* Save loglevel */
330330

331331
hdr = (void *)early_log_buffer + early_log_buf_off;
332332
hdr->level = loglevel;
333333
/* Skip the log entry size */
334-
early_log_buf_off += sizeof(hdr);
334+
early_log_buf_off += sizeof(*hdr);
335335
log_space = EARLY_LOG_BUF_LEN - early_log_buf_off;
336336
if (loglevel >= LOG_TIMESTAMP) {
337337
/*

0 commit comments

Comments
 (0)