Skip to content

Commit

Permalink
save-view: fix some printf format specifiers
Browse files Browse the repository at this point in the history
Commit 175f658 ("Test diff stat parsing", 10-07-2017) added a new
'save-view' command to dump the view data as a facility to help in
debugging. In order to dump the data, some variables of type size_t
are printed using an '%ld' fprintf() format specifier. On 64-bit
platforms this is not a problem, since size_t is effectively the
same as an 'unsigned long int'. However, on 32-bit systems, this will
cause compiler warnings to be issued, since size_t is effectively an
'unsigned int' type. In order to print a size_t variable on both
platforms, without provoking compiler warnings, use the '%zu' format
specifier.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Jonas Fonseca <jonas.fonseca@gmail.com>
  • Loading branch information
ramsay-jones authored and jonas committed Jul 17, 2017
1 parent dd34b2b commit 5945563
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ save_view(struct view *view, const char *path)
for (i = 0; i < view->lines; i++) {
struct line *line = &view->line[i];

fprintf(file, "line[%3ld] type=%s selected=%d\n",
fprintf(file, "line[%3zu] type=%s selected=%d\n",
i,
enum_name(get_line_type_name(line->type)),
line->selected);
Expand All @@ -393,7 +393,7 @@ save_view(struct view *view, const char *path)
size_t j;
size_t offset;

fprintf(file, "line[%3ld] cells=%ld text=",
fprintf(file, "line[%3zu] cells=%zu text=",
i, box->cells);

for (j = 0, offset = 0; j < box->cells; j++) {
Expand Down

0 comments on commit 5945563

Please sign in to comment.