public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ferruh.yigit at intel dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/95818] New: wrong "used uninitialized" warning
Date: Mon, 22 Jun 2020 12:53:46 +0000	[thread overview]
Message-ID: <bug-95818-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95818

            Bug ID: 95818
           Summary: wrong "used uninitialized" warning
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ferruh.yigit at intel dot com
  Target Milestone: ---

gcc (GCC) 11.0.0 20200621 (experimental)

Sorry, I couldn't able to reproduce with test code, I will copy-paste the real
code that causes the warning hoping it helps.

Warning [1] and code that causes it [2], struct in question [3].

As you can see all the fields of the struct has been set before used, so not
sure why giving used uninitialized warning.



[1]
.../drivers/net/iavf/iavf_ethdev.c: In function ‘iavf_dev_link_update’:
.../drivers/net/iavf/iavf_ethdev.c:641:6: error: ‘new_link’ is used
uninitialized [-Werror=uninitialized]
  641 |  if (rte_atomic64_cmpset((uint64_t *)&dev->data->dev_link,
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  642 |     *(uint64_t *)&dev->data->dev_link,
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  643 |     *(uint64_t *)&new_link) == 0)
      |     ~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/iavf/iavf_ethdev.c:596:22: note: ‘new_link’ declared here
  596 |  struct rte_eth_link new_link;
      |                      ^~~~~~~~
cc1: all warnings being treated as error



[2]
iavf_dev_link_update(struct rte_eth_dev *dev,
                    __rte_unused int wait_to_complete)
{
        struct rte_eth_link new_link;
        struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);

        /* Only read status info stored in VF, and the info is updated
         *  when receive LINK_CHANGE evnet from PF by Virtchnnl.
         */
        switch (vf->link_speed) {
        case 10:
                new_link.link_speed = ETH_SPEED_NUM_10M;
                break;
        case 100:
                new_link.link_speed = ETH_SPEED_NUM_100M;
                break;
        case 1000:
                new_link.link_speed = ETH_SPEED_NUM_1G;
                break;
        case 10000:
                new_link.link_speed = ETH_SPEED_NUM_10G;
                break;
        case 20000:
                new_link.link_speed = ETH_SPEED_NUM_20G;
                break;
        case 25000:
                new_link.link_speed = ETH_SPEED_NUM_25G;
                break;
        case 40000:
                new_link.link_speed = ETH_SPEED_NUM_40G;
                break;
        case 50000:
                new_link.link_speed = ETH_SPEED_NUM_50G;
                break;
        case 100000:
                new_link.link_speed = ETH_SPEED_NUM_100G;
                break;
        default:
                new_link.link_speed = ETH_SPEED_NUM_NONE;
                break;
        }

        new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
        new_link.link_status = vf->link_up ? ETH_LINK_UP :
                                             ETH_LINK_DOWN;
        new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
                                ETH_LINK_SPEED_FIXED);

        if (rte_atomic64_cmpset((uint64_t *)&dev->data->dev_link,
                                *(uint64_t *)&dev->data->dev_link,
                                *(uint64_t *)&new_link) == 0)
                return -1;

        return 0;
}



[3]
struct rte_eth_link {
        uint32_t link_speed;        /**< ETH_SPEED_NUM_ */
        uint16_t link_duplex  : 1;  /**< ETH_LINK_[HALF/FULL]_DUPLEX */
        uint16_t link_autoneg : 1;  /**< ETH_LINK_[AUTONEG/FIXED] */
        uint16_t link_status  : 1;  /**< ETH_LINK_[DOWN/UP] */
} __rte_aligned(8);      /**< aligned for atomic64 read/write */

             reply	other threads:[~2020-06-22 12:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 12:53 ferruh.yigit at intel dot com [this message]
2020-06-22 13:00 ` [Bug c/95818] " rguenth at gcc dot gnu.org
2020-06-22 15:11 ` ferruh.yigit at intel dot com
2020-06-22 19:29 ` glisse at gcc dot gnu.org
2020-06-22 23:55 ` ferruh.yigit at intel dot com
2020-06-22 23:59 ` ferruh.yigit at intel dot com
2020-06-23  0:21 ` [Bug middle-end/95818] " msebor at gcc dot gnu.org
2020-06-23  0:35 ` ferruh.yigit at intel dot com
2020-06-23  1:58 ` msebor at gcc dot gnu.org

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=bug-95818-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).