Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tools/logger/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,10 @@ static int logger_read(void)
freopen(NULL, "r", global_config->in_fd);
continue;
}

return -ferror(global_config->in_fd);
log_err("in %s(), fread(..., %s) failed: %s(%d)\n",
__func__, global_config->in_file,
strerror(errno), errno);
return -errno;
}

/* checking if received trace address is located in
Expand Down
2 changes: 1 addition & 1 deletion tools/logger/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static int append_filter_config(struct convert_config *config, const char *input

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc-hb can you explain why do we need this commit?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commit turn on printf like formatting string vs argument list check in compilation time for asprintf and log_err functions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The printf attribute finds run-time memory corruption at compile time, always seemed very useful to me. It works with clang too BTW (tested).

/* filer_config can't be NULL for following steps */
if (!old_config)
config->filter_config = asprintf("");
config->filter_config = asprintf("%s", "");

config->filter_config = asprintf("%s%s\n", config->filter_config, input);
free(old_config);
Expand Down
7 changes: 7 additions & 0 deletions tools/logger/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
#include <stdlib.h>

char *vasprintf(const char *format, va_list args);

#ifdef __GNUC__
__attribute__((format(printf, 1, 2)))
#endif
char *asprintf(const char *format, ...);

#ifdef __GNUC__
__attribute__((format(printf, 1, 2)))
#endif
void log_err(const char *fmt, ...);

/* trim whitespaces from string begin */
Expand Down