mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
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 <kolyshkin@gmail.com> Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
parent
e689d902b3
commit
0a7e7d09dd
1 changed files with 3 additions and 3 deletions
|
|
@ -190,7 +190,7 @@ void flush_early_log_buffer(int fd)
|
||||||
* with reading the log_level.
|
* with reading the log_level.
|
||||||
*/
|
*/
|
||||||
struct early_log_hdr *hdr = (void *)early_log_buffer + pos;
|
struct early_log_hdr *hdr = (void *)early_log_buffer + pos;
|
||||||
pos += sizeof(hdr);
|
pos += sizeof(*hdr);
|
||||||
if (hdr->level <= current_loglevel) {
|
if (hdr->level <= current_loglevel) {
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
while (size < hdr->len) {
|
while (size < hdr->len) {
|
||||||
|
|
@ -323,7 +323,7 @@ static void early_vprint(const char *format, unsigned int loglevel, va_list para
|
||||||
int log_size = 0, log_space;
|
int log_size = 0, log_space;
|
||||||
struct early_log_hdr *hdr;
|
struct early_log_hdr *hdr;
|
||||||
|
|
||||||
if ((early_log_buf_off + sizeof(hdr)) >= EARLY_LOG_BUF_LEN)
|
if ((early_log_buf_off + sizeof(*hdr)) >= EARLY_LOG_BUF_LEN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Save loglevel */
|
/* Save loglevel */
|
||||||
|
|
@ -331,7 +331,7 @@ static void early_vprint(const char *format, unsigned int loglevel, va_list para
|
||||||
hdr = (void *)early_log_buffer + early_log_buf_off;
|
hdr = (void *)early_log_buffer + early_log_buf_off;
|
||||||
hdr->level = loglevel;
|
hdr->level = loglevel;
|
||||||
/* Skip the log entry size */
|
/* Skip the log entry size */
|
||||||
early_log_buf_off += sizeof(hdr);
|
early_log_buf_off += sizeof(*hdr);
|
||||||
log_space = EARLY_LOG_BUF_LEN - early_log_buf_off;
|
log_space = EARLY_LOG_BUF_LEN - early_log_buf_off;
|
||||||
if (loglevel >= LOG_TIMESTAMP) {
|
if (loglevel >= LOG_TIMESTAMP) {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue