Skip to content

Commit

Permalink
Fix gcc-12 compiler warnings on lkcd_*.c
Browse files Browse the repository at this point in the history
Without the patch, the following gcc-12 compiler warnings are emitted
for lkcd_*.c:

lkcd_v1.c: In function 'dump_lkcd_environment_v1':
lkcd_v1.c:252:20: warning: the comparison will always evaluate as 'true' for the address of 'dh_panic_string' will never be NULL [-Waddress]
  252 |                 dh && dh->dh_panic_string &&
      |                    ^~
In file included from lkcd_v1.c:21:
lkcd_vmdump_v1.h:108:30: note: 'dh_panic_string' declared here
  108 |         char                 dh_panic_string[DUMP_PANIC_LEN];
      |                              ^~~~~~~~~~~~~~~
...

Reported-by: Lianbo Jiang <[email protected]>
Signed-off-by: Kazuhito Hagio <[email protected]>
  • Loading branch information
k-hagio committed Sep 2, 2022
1 parent 5b9d3e9 commit 51acac7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lkcd_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ dump_lkcd_environment_v1(ulong arg)
lkcd_print(" dh_eip: %lx\n", dh->dh_eip);
lkcd_print(" dh_num_pages: %d\n", dh->dh_num_pages);
lkcd_print(" dh_panic_string: %s%s", dh->dh_panic_string,
dh && dh->dh_panic_string &&
strstr(dh->dh_panic_string, "\n") ? "" : "\n");
dh && strstr(dh->dh_panic_string, "\n") ? "" : "\n");
lkcd_print(" dh_time: %s\n",
strip_linefeeds(ctime(&(dh->dh_time.tv_sec))));

Expand Down
3 changes: 1 addition & 2 deletions lkcd_v2_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ dump_lkcd_environment_v2_v3(ulong arg)
lkcd_print(" dh_num_pages: ");
lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_num_pages);
lkcd_print(" dh_panic_string: %s%s", dh->dh_panic_string,
dh && dh->dh_panic_string &&
strstr(dh->dh_panic_string, "\n") ? "" : "\n");
dh && strstr(dh->dh_panic_string, "\n") ? "" : "\n");
lkcd_print(" dh_time: %s\n",
strip_linefeeds(ctime(&(dh->dh_time.tv_sec))));

Expand Down
3 changes: 1 addition & 2 deletions lkcd_v5.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ dump_lkcd_environment_v5(ulong arg)
lkcd_print(" dh_num_pages: ");
lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_num_pages);
lkcd_print(" dh_panic_string: %s%s", dh->dh_panic_string,
dh && dh->dh_panic_string &&
strstr(dh->dh_panic_string, "\n") ? "" : "\n");
dh && strstr(dh->dh_panic_string, "\n") ? "" : "\n");
lkcd_print(" dh_time: %s\n",
strip_linefeeds(ctime(&(dh->dh_time.tv_sec))));

Expand Down
3 changes: 1 addition & 2 deletions lkcd_v7.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ dump_lkcd_environment_v7(ulong arg)
lkcd_print(" dh_num_pages: ");
lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_num_pages);
lkcd_print(" dh_panic_string: %s%s", dh->dh_panic_string,
dh && dh->dh_panic_string &&
strstr(dh->dh_panic_string, "\n") ? "" : "\n");
dh && strstr(dh->dh_panic_string, "\n") ? "" : "\n");
lkcd_print(" dh_time: %s\n",
strip_linefeeds(ctime(&(dh->dh_time.tv_sec))));

Expand Down
3 changes: 1 addition & 2 deletions lkcd_v8.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,7 @@ dump_lkcd_environment_v8(ulong arg)
lkcd_print(" dh_num_pages: ");
lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_num_pages);
lkcd_print(" dh_panic_string: %s%s", dh->dh_panic_string,
dh && dh->dh_panic_string &&
strstr(dh->dh_panic_string, "\n") ? "" : "\n");
dh && strstr(dh->dh_panic_string, "\n") ? "" : "\n");
tv.tv_sec = dh->dh_time.tv_sec;
lkcd_print(" dh_time: %s\n",
strip_linefeeds(ctime(&(tv.tv_sec))));
Expand Down

0 comments on commit 51acac7

Please sign in to comment.