drivers/staging/vme_user/vme_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
struct image_desc and vme_user_vma_priv are used only in vme_user.c file.
Added keyword static to these struct definition to limit its scope and
potentially allow for compiler optimizations.
Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
---
drivers/staging/vme_user/vme_user.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/vme_user/vme_user.c b/drivers/staging/vme_user/vme_user.c
index 5829a4141561..fe1026857710 100644
--- a/drivers/staging/vme_user/vme_user.c
+++ b/drivers/staging/vme_user/vme_user.c
@@ -88,7 +88,7 @@ static unsigned int bus_num;
/*
* Structure to handle image related parameters.
*/
-struct image_desc {
+static struct image_desc {
void *kern_buf; /* Buffer address in kernel space */
dma_addr_t pci_buf; /* Buffer address in PCI address space */
unsigned long long size_buf; /* Buffer size */
@@ -114,7 +114,7 @@ static const int type[VME_DEVS] = { MASTER_MINOR, MASTER_MINOR,
CONTROL_MINOR
};
-struct vme_user_vma_priv {
+static struct vme_user_vma_priv {
unsigned int minor;
refcount_t refcnt;
};
--
2.46.0
Hi Riyan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/Riyan-Dhiman/staging-vme_user-Added-static-to-image_desc-and-vme_user_vma_priv-struct/20240826-142747
base: staging/staging-testing
patch link: https://lore.kernel.org/r/20240825035514.40095-1-riyandhiman14%40gmail.com
patch subject: [PATCH] staging: vme_user: Added static to image_desc and vme_user_vma_priv struct
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20240827/202408270655.m9x8rJA5-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240827/202408270655.m9x8rJA5-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408270655.m9x8rJA5-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/staging/vme_user/vme_user.c:99:1: warning: useless storage class specifier in empty declaration
99 | };
| ^
drivers/staging/vme_user/vme_user.c:120:1: warning: useless storage class specifier in empty declaration
120 | };
| ^
vim +99 drivers/staging/vme_user/vme_user.c
f00a86d98a1ec3 drivers/staging/vme/devices/vme_user.c Martyn Welch 2009-07-31 87
f00a86d98a1ec3 drivers/staging/vme/devices/vme_user.c Martyn Welch 2009-07-31 88 /*
f00a86d98a1ec3 drivers/staging/vme/devices/vme_user.c Martyn Welch 2009-07-31 89 * Structure to handle image related parameters.
f00a86d98a1ec3 drivers/staging/vme/devices/vme_user.c Martyn Welch 2009-07-31 90 */
e2d30086b6cc13 drivers/staging/vme_user/vme_user.c Riyan Dhiman 2024-08-25 91 static struct image_desc {
0a81a0f768e5bb drivers/staging/vme/devices/vme_user.c Emilio G. Cota 2010-11-12 92 void *kern_buf; /* Buffer address in kernel space */
f00a86d98a1ec3 drivers/staging/vme/devices/vme_user.c Martyn Welch 2009-07-31 93 dma_addr_t pci_buf; /* Buffer address in PCI address space */
f00a86d98a1ec3 drivers/staging/vme/devices/vme_user.c Martyn Welch 2009-07-31 94 unsigned long long size_buf; /* Buffer size */
ecb3b80ff968f1 drivers/staging/vme/devices/vme_user.c Santosh Nayak 2012-04-03 95 struct mutex mutex; /* Mutex for locking image */
f00a86d98a1ec3 drivers/staging/vme/devices/vme_user.c Martyn Welch 2009-07-31 96 struct device *device; /* Sysfs device */
f00a86d98a1ec3 drivers/staging/vme/devices/vme_user.c Martyn Welch 2009-07-31 97 struct vme_resource *resource; /* VME resource */
c74a804f115bde drivers/staging/vme/devices/vme_user.c Dmitry Kalinkin 2015-02-26 98 int mmap_count; /* Number of current mmap's */
584721cab2bdd2 drivers/staging/vme/devices/vme_user.c Vincent Bossier 2011-06-03 @99 };
cd974d35ab784d drivers/staging/vme/devices/vme_user.c Dmitry Kalinkin 2015-06-26 100
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Riyan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/Riyan-Dhiman/staging-vme_user-Added-static-to-image_desc-and-vme_user_vma_priv-struct/20240826-142747
base: staging/staging-testing
patch link: https://lore.kernel.org/r/20240825035514.40095-1-riyandhiman14%40gmail.com
patch subject: [PATCH] staging: vme_user: Added static to image_desc and vme_user_vma_priv struct
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20240827/202408270621.ILLZ4jZN-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 08e5a1de8227512d4774a534b91cb2353cef6284)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240827/202408270621.ILLZ4jZN-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408270621.ILLZ4jZN-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from drivers/staging/vme_user/vme_user.c:16:
In file included from include/linux/cdev.h:8:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:528:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
528 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
529 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/staging/vme_user/vme_user.c:19:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from drivers/staging/vme_user/vme_user.c:19:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from drivers/staging/vme_user/vme_user.c:19:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> drivers/staging/vme_user/vme_user.c:91:1: warning: 'static' ignored on this declaration [-Wmissing-declarations]
91 | static struct image_desc {
| ^
drivers/staging/vme_user/vme_user.c:117:1: warning: 'static' ignored on this declaration [-Wmissing-declarations]
117 | static struct vme_user_vma_priv {
| ^
19 warnings generated.
vim +/static +91 drivers/staging/vme_user/vme_user.c
87
88 /*
89 * Structure to handle image related parameters.
90 */
> 91 static struct image_desc {
92 void *kern_buf; /* Buffer address in kernel space */
93 dma_addr_t pci_buf; /* Buffer address in PCI address space */
94 unsigned long long size_buf; /* Buffer size */
95 struct mutex mutex; /* Mutex for locking image */
96 struct device *device; /* Sysfs device */
97 struct vme_resource *resource; /* VME resource */
98 int mmap_count; /* Number of current mmap's */
99 };
100
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Sun, Aug 25, 2024 at 09:25:14AM +0530, Riyan Dhiman wrote: > struct image_desc and vme_user_vma_priv are used only in vme_user.c file. > Added keyword static to these struct definition to limit its scope and > potentially allow for compiler optimizations. I'm not sure if there is any optimization that compilers can do, when we tell it that the struct definitions are local. Did Gcc not complain when you compile this patch? Because it did for me.. Best regards, Nam
© 2016 - 2025 Red Hat, Inc.