lkml.org 
[lkml]   [2021]   [Aug]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    Subjectdrivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument
    tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
    head: f8e6dfc64f6135d1b6c5215c14cd30b9b60a0008
    commit: d86481e924a7d6e8a40477ffa98077c6c0d77ed5 nvmet: use min of device_path and disk len
    date: 6 months ago
    config: powerpc-randconfig-c023-20210812 (attached as .config)
    compiler: powerpc-linux-gcc (GCC) 11.2.0
    reproduce (this is a W=1 build):
    wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
    chmod +x ~/bin/make.cross
    # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d86481e924a7d6e8a40477ffa98077c6c0d77ed5
    git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
    git fetch --no-tags linus master
    git checkout d86481e924a7d6e8a40477ffa98077c6c0d77ed5
    # save the attached .config to linux build tree
    COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=powerpc

    If you fix the issue, kindly add following tag as appropriate
    Reported-by: kernel test robot <lkp@intel.com>

    All warnings (new ones prefixed by >>):

    In file included from drivers/nvme/target/core.c:14:
    In function '__assign_req_name',
    inlined from 'trace_event_raw_event_nvmet_req_init' at drivers/nvme/target/./trace.h:61:1:
    >> drivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
    56 | strncpy(name, req->ns->device_path,
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    57 | min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from include/linux/kernel.h:14,
    from include/linux/list.h:9,
    from include/linux/module.h:12,
    from drivers/nvme/target/core.c:7:
    drivers/nvme/target/./trace.h: In function 'trace_event_raw_event_nvmet_req_init':
    drivers/nvme/target/trace.h:57:46: note: length computed here
    57 | min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
    include/linux/minmax.h:38:39: note: in definition of macro '__cmp_once'
    38 | typeof(y) unique_y = (y); \
    | ^
    include/linux/minmax.h:110:33: note: in expansion of macro '__careful_cmp'
    110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
    | ^~~~~~~~~~~~~
    drivers/nvme/target/trace.h:57:17: note: in expansion of macro 'min_t'
    57 | min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
    | ^~~~~
    In file included from drivers/nvme/target/core.c:14:
    In function '__assign_req_name',
    inlined from 'trace_event_raw_event_nvmet_req_complete' at drivers/nvme/target/./trace.h:103:1:
    >> drivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
    56 | strncpy(name, req->ns->device_path,
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    57 | min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from include/linux/kernel.h:14,
    from include/linux/list.h:9,
    from include/linux/module.h:12,
    from drivers/nvme/target/core.c:7:
    drivers/nvme/target/./trace.h: In function 'trace_event_raw_event_nvmet_req_complete':
    drivers/nvme/target/trace.h:57:46: note: length computed here
    57 | min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
    include/linux/minmax.h:38:39: note: in definition of macro '__cmp_once'
    38 | typeof(y) unique_y = (y); \
    | ^
    include/linux/minmax.h:110:33: note: in expansion of macro '__careful_cmp'
    110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
    | ^~~~~~~~~~~~~
    drivers/nvme/target/trace.h:57:17: note: in expansion of macro 'min_t'
    57 | min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
    | ^~~~~


    vim +/strncpy +56 drivers/nvme/target/trace.h

    48
    49 static inline void __assign_req_name(char *name, struct nvmet_req *req)
    50 {
    51 if (!req->ns) {
    52 memset(name, 0, DISK_NAME_LEN);
    53 return;
    54 }
    55
    > 56 strncpy(name, req->ns->device_path,
    57 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
    58 }
    59 #endif
    60

    ---
    0-DAY CI Kernel Test Service, Intel Corporation
    https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
    [unhandled content-type:application/gzip]
    \
     
     \ /
      Last update: 2021-08-13 17:29    [W:2.661 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site