All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: dsahern@gmail.com
Cc: linux-kselftest@vger.kernel.org
Subject: [bug report] selftests: Add nettest
Date: Wed, 14 Aug 2019 17:12:24 +0300	[thread overview]
Message-ID: <20190814141224.GA32264@mwanda> (raw)

Hello David Ahern,

The patch acda655fefae: "selftests: Add nettest" from Aug 1, 2019,
leads to the following static checker warning:

	./tools/testing/selftests/net/nettest.c:1690 main()
	warn: unsigned 'tmp' is never less than zero.

./tools/testing/selftests/net/nettest.c
  1680                  case '1':
  1681                          args.has_expected_raddr = 1;
  1682                          if (convert_addr(&args, optarg,
  1683                                           ADDR_TYPE_EXPECTED_REMOTE))
  1684                                  return 1;
  1685  
  1686                          break;
  1687                  case '2':
  1688                          if (str_to_uint(optarg, 0, 0x7ffffff, &tmp) != 0) {
  1689                                  tmp = get_ifidx(optarg);
  1690                                  if (tmp < 0) {

"tmp" is unsigned so it can't be negative.  Also all the callers assume
that get_ifidx() returns negatives on error but it looks like it really
returns zero on error so it's a bit unclear to me.

  1691                                          fprintf(stderr,
  1692                                                  "Invalid device index\n");
  1693                                          return 1;
  1694                                  }
  1695                          }
  1696                          args.expected_ifindex = (int)tmp;
  1697                          break;
  1698                  case 'q':
  1699                          quiet = 1;

regards,
dan carpenter

             reply	other threads:[~2019-08-14 14:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14 14:12 Dan Carpenter [this message]
2019-08-14 14:50 ` [bug report] selftests: Add nettest David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190814141224.GA32264@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=dsahern@gmail.com \
    --cc=linux-kselftest@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.