On Tue, May 11, 2021 at 09:51:22AM +0200, Claudio Jeker wrote:
> Modern gcc warns about these variables being not initalized.
>
> main.c: In function 'main':
> main.c:1064:11: warning: 'rrdppid' may be used uninitialized in this function
> [-Wmaybe-uninitialized]
> else if (pid == rrdppid)
> ^
>
> rrdp_delta.c: In function 'start_publish_withdraw_elem':
> rrdp_delta.c:150:15: warning: 'uri' may be used uninitialized in this
> function [-Wmaybe-uninitialized]
> dxml->pxml = new_publish_xml(pub, uri, hash,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> hasHash ? sizeof(hash) : 0);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> rrdp_notification.c: In function 'notification_done':
> rrdp_notification.c:380:5: warning: 'last_s' may be used uninitialized in
> this function [-Wmaybe-uninitialized]
> if (last_s != nxml->serial)
> ^
>
> The main.c change just adds the same bit of code that the other
> sub-processes use (http and rsync). For the rrdp files I think the could
> is not reachable with the variable uninitalized but it is for sure not
> obvious so better make it explicit.
I agree that these are false positives in the rrdp code.
ok
>
> --
> :wq Claudio
>
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v
> retrieving revision 1.139
> diff -u -p -r1.139 main.c
> --- main.c 19 Apr 2021 17:04:35 -0000 1.139
> +++ main.c 11 May 2021 07:49:09 -0000
> @@ -855,8 +855,10 @@ main(int argc, char *argv[])
>
> close(fd[0]);
> rrdp = fd[1];
> - } else
> + } else {
> rrdp = -1;
> + rrdppid = -1;
> + }
>
> /* TODO unveil cachedir and outputdir, no other access allowed */
> if (pledge("stdio rpath wpath cpath fattr sendfd", NULL) == -1)
> Index: rrdp_delta.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/rrdp_delta.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 rrdp_delta.c
> --- rrdp_delta.c 1 Apr 2021 16:04:48 -0000 1.1
> +++ rrdp_delta.c 10 May 2021 13:12:36 -0000
> @@ -115,7 +115,7 @@ start_publish_withdraw_elem(struct delta
> int withdraw)
> {
> XML_Parser p = dxml->parser;
> - char *uri, hash[SHA256_DIGEST_LENGTH];
> + char *uri = NULL, hash[SHA256_DIGEST_LENGTH];
> int i, hasUri = 0, hasHash = 0;
> enum publish_type pub = PUB_UPD;
>
> Index: rrdp_notification.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/rrdp_notification.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 rrdp_notification.c
> --- rrdp_notification.c 15 Apr 2021 08:58:46 -0000 1.4
> +++ rrdp_notification.c 10 May 2021 13:14:18 -0000
> @@ -351,7 +351,7 @@ enum rrdp_task
> notification_done(struct notification_xml *nxml, char *last_mod)
> {
> struct delta_item *d;
> - long long s, last_s;
> + long long s, last_s = 0;
>
> nxml->current->last_mod = last_mod;
> nxml->current->session_id = xstrdup(nxml->session_id);
>