Re: Intel i40e code finds smatch bug

Dan McDonald <[email protected]>
Newsgroups org.kernel.vger.smatch
Message-ID <[email protected]>
On Jan 19, 2021, at 1:55 PM, Dan Carpenter <[email protected]> wrote:
> 
> Luk recently was working on better support of packed structs (which have
> been a known issue for a while) but I doubt that will help here.

I tried using packed struct attributes instead of the pragma and no luck there either:

centos(~)[0]% diff -u pack.c pack2.c
--- pack.c	2021-01-19 17:16:13.258512270 +0000
+++ pack2.c	2021-01-19 20:49:45.886696658 +0000
@@ -6,9 +6,8 @@
 #define __le16 uint16_t
 #define __le32 uint32_t
 
-#pragma pack(1)
 /* Run PHY Activity (0x0626) */
-struct i40e_aqc_run_phy_activity {
+struct __attribute__((packed)) i40e_aqc_run_phy_activity {
         u8      cmd_flags;
         __le16  activity_id;
 #define I40E_AQ_RUN_PHY_ACT_ID_USR_DFND                 0x10
@@ -31,7 +30,6 @@
                 } resp;
    } params;
 };
-#pragma pack()
 
 #define I40E_CHECK_STRUCT_LEN(n, X) enum i40e_static_assert_enum_##X \
         { i40e_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
centos(~)[1]% 


Dan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.