On Thu, Mar 18, 2021 at 11:25:25AM +0100, Claudio Jeker wrote:
> This diff aims at removing some warnings seen in -portable.
>
> - gcc has a hard time to realize when a variable like noop ensures that
> an other variable is not used.
>
> - Similar the switch () statements in http.c include all possible enums but
> gcc warns about control reaches end of non-void function.
>
> - Assigning the return value of asprintf() to a size_t is problematic. Do it
> in two steps.
>
> - Also remove the no longer used repo index from struct entity.
ok tb
>
> --
> :wq Claudio
>
> Index: extern.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v
> retrieving revision 1.53
> diff -u -p -r1.53 extern.h
> --- extern.h 5 Mar 2021 17:15:19 -0000 1.53
> +++ extern.h 18 Mar 2021 09:11:43 -0000
> @@ -271,7 +271,6 @@ enum rtype {
> struct entity {
> enum rtype type; /* type of entity (not RTYPE_EOF) */
> char *file; /* local path to file */
> - ssize_t repo; /* repo index or <0 if w/o repo */
> int has_pkey; /* whether pkey/sz is specified */
> unsigned char *pkey; /* public key (optional) */
> size_t pkeysz; /* public key length (optional) */
> Index: http.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/http.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 http.c
> --- http.c 4 Mar 2021 15:44:13 -0000 1.5
> +++ http.c 18 Mar 2021 07:33:20 -0000
> @@ -596,7 +596,7 @@ static int
> http_request(struct http_connection *conn)
> {
> char *host, *epath, *modified_since;
> - int with_port = 0;
> + int r, with_port = 0;
>
> /* TODO adjust request for HTTP proxy setups */
>
> @@ -634,7 +634,7 @@ http_request(struct http_connection *con
>
> free(conn->buf);
> conn->bufpos = 0;
> - if ((conn->bufsz = asprintf(&conn->buf,
> + if ((r = asprintf(&conn->buf,
> "GET /%s HTTP/1.1\r\n"
> "Connection: close\r\n"
> "User-Agent: " HTTP_USER_AGENT "\r\n"
> @@ -642,6 +642,7 @@ http_request(struct http_connection *con
> epath, host,
> modified_since ? modified_since : "")) == -1)
> err(1, NULL);
> + conn->bufsz = r;
>
> free(epath);
> free(host);
> @@ -1032,6 +1033,7 @@ http_handle(struct http_connection *conn
> case STATE_FREE:
> errx(1, "bad http state");
> }
> + errx(1, "unknown http state");
> }
>
> static int
> @@ -1084,6 +1086,7 @@ http_nextstep(struct http_connection *co
> case STATE_FREE:
> errx(1, "bad http state");
> }
> + errx(1, "unknown http state");
> }
>
> static int
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v
> retrieving revision 1.119
> diff -u -p -r1.119 main.c
> --- main.c 15 Mar 2021 08:56:31 -0000 1.119
> +++ main.c 18 Mar 2021 09:12:55 -0000
> @@ -1018,8 +1018,10 @@ main(int argc, char *argv[])
>
> close(fd[0]);
> rsync = fd[1];
> - } else
> + } else {
> rsync = -1;
> + rsyncpid = -1;
> + }
>
> /*
> * Create a process that will fetch data via https.
> @@ -1051,8 +1053,10 @@ main(int argc, char *argv[])
>
> close(fd[0]);
> http = fd[1];
> - } else
> + } else {
> http = -1;
> + httppid = -1;
> + }
>
> if (pledge("stdio rpath wpath cpath fattr sendfd", NULL) == -1)
> err(1, "pledge");
>