public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95818] New: wrong "used uninitialized" warning
@ 2020-06-22 12:53 ferruh.yigit at intel dot com
  2020-06-22 13:00 ` [Bug c/95818] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ferruh.yigit at intel dot com @ 2020-06-22 12:53 UTC (permalink / raw)
  To: gcc-bugs

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 */

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-06-23  1:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 12:53 [Bug c/95818] New: wrong "used uninitialized" warning ferruh.yigit at intel dot com
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

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).