checkpolicy.c: In function ‘main’: checkpolicy.c:1000:25: error: ‘tsid’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1000 | printf("if_sid %d default_msg_sid %d\n", ssid, tsid); | ^ checkpolicy.c: In function ‘main’: checkpolicy.c:971:25: error: ‘tsid’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 971 | printf("fs_sid %d default_file_sid %d\n", ssid, tsid); | ^ Found by GCC 11 with LTO enabled. Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- checkpolicy/checkpolicy.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c index c88ca542..04f35eda 100644 --- a/checkpolicy/checkpolicy.c +++ b/checkpolicy/checkpolicy.c @@ -967,8 +967,12 @@ int main(int argc, char **argv) printf("fs kdevname? "); FGETS(ans, sizeof(ans), stdin); ans[strlen(ans) - 1] = 0; - sepol_fs_sid(ans, &ssid, &tsid); - printf("fs_sid %d default_file_sid %d\n", ssid, tsid); + ret = sepol_fs_sid(ans, &ssid, &tsid); + if (ret) { + printf("unknown fs kdevname\n"); + } else { + printf("fs_sid %d default_file_sid %d\n", ssid, tsid); + } break; case '9': printf("protocol? "); @@ -996,8 +1000,12 @@ int main(int argc, char **argv) printf("netif name? "); FGETS(ans, sizeof(ans), stdin); ans[strlen(ans) - 1] = 0; - sepol_netif_sid(ans, &ssid, &tsid); - printf("if_sid %d default_msg_sid %d\n", ssid, tsid); + ret = sepol_netif_sid(ans, &ssid, &tsid); + if (ret) { + printf("unknown name\n"); + } else { + printf("if_sid %d default_msg_sid %d\n", ssid, tsid); + } break; case 'b':{ char *p; -- 2.32.0