[PATCH] tftpDriver.c: Fix Coverity issues

Joel Sherrill joel at rtems.org
Fri Sep 16 18:47:34 UTC 2022


I'm ok with this.

FYI Coverity Scans are limited to three times a day but a check for changes
runs more frequently to trigger them.

On Fri, Sep 16, 2022, 1:13 PM Frank Kuehndel <
frank.kuehndel at embedded-brains.de> wrote:

> From: Frank Kühndel <frank.kuehndel at embedded-brains.de>
>
> CID 1506523: Unchecked return value from library (CHECKED_RETURN)
> CID 1506522: Unchecked return value from library (CHECKED_RETURN)
> CID 1437618: Unchecked return value from library (CHECKED_RETURN)
>
> Close #4718
> ---
>  cpukit/libfs/src/ftpfs/tftpDriver.c | 27 ++++++++++++++++++++++-----
>  1 file changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/cpukit/libfs/src/ftpfs/tftpDriver.c
> b/cpukit/libfs/src/ftpfs/tftpDriver.c
> index 59136ef59f..0246ed9611 100644
> --- a/cpukit/libfs/src/ftpfs/tftpDriver.c
> +++ b/cpukit/libfs/src/ftpfs/tftpDriver.c
> @@ -525,8 +525,10 @@ static void send_error (
>
>      /*
>       * Send it
> +     *
> +     * Ignoring result because error packets are sent once and maybe lost.
>       */
> -    sendto (tp->socket, (char *)&msg, len, 0, (struct sockaddr *)to,
> sizeof *to);
> +    (void) sendto (tp->socket, (char *)&msg, len, 0, (struct sockaddr
> *)to, sizeof *to);
>  }
>
>  /*
> @@ -552,11 +554,21 @@ getPacket (struct tftpStream *tp, int retryCount)
>      } else if (retryCount == 0) {
>          tv.tv_sec = tp->config.first_timeout / 1000L;
>          tv.tv_usec = (tp->config.first_timeout % 1000L) * 1000L;
> -        setsockopt (tp->socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
> +        /*
> +         * Ignoring result because all possible errors indicate wrong
> +         * arguments and these arguments are OK as tested by test suite.
> +         */
> +        (void) setsockopt (tp->socket, SOL_SOCKET, SO_RCVTIMEO, &tv,
> +            sizeof tv);
>      } else {
>          tv.tv_sec = tp->config.timeout / 1000L;
>          tv.tv_usec = (tp->config.timeout % 1000L) * 1000L;
> -        setsockopt (tp->socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
> +        /*
> +         * Ignoring result because all possible errors indicate wrong
> +         * arguments and these arguments are OK as tested by test suite.
> +         */
> +        (void) setsockopt (tp->socket, SOL_SOCKET, SO_RCVTIMEO, &tv,
> +            sizeof tv);
>      }
>      for (;;) {
>          union {
> @@ -591,7 +603,12 @@ getPacket (struct tftpStream *tp, int retryCount)
>      if (retryCount != GET_PACKET_DONT_WAIT) {
>          tv.tv_sec = 0;
>          tv.tv_usec = 0;
> -        setsockopt (tp->socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
> +        /*
> +         * Ignoring result because all possible errors indicate wrong
> +         * arguments and these arguments are OK as tested by test suite.
> +         */
> +        (void) setsockopt (tp->socket, SOL_SOCKET, SO_RCVTIMEO, &tv,
> +            sizeof tv);
>      }
>      return len;
>  }
> @@ -724,7 +741,7 @@ static int process_data_packet (struct tftpStream *tp,
> ssize_t len)
>          /*
>           * Send it. Errors during send will not matter for this last ACK.
>           */
> -        sendto (
> +        (void) sendto (
>              tp->socket,
>              send_buf,
>              plen,
> --
> 2.35.3
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20220916/e813238f/attachment.htm>


More information about the devel mailing list