Skip to content

Commit

Permalink
checkpolicy: avoid potential use of uninitialized variable
Browse files Browse the repository at this point in the history
    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@googlemail.com>
  • Loading branch information
cgzones authored and fishilico committed Jul 13, 2021
1 parent 5a10f05 commit 5218bf4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions checkpolicy/checkpolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,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? ");
Expand Down Expand Up @@ -999,8 +1003,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;
Expand Down

0 comments on commit 5218bf4

Please sign in to comment.