From: kernel test robot <lkp@intel.com>
To: Paulo Alcantara <pc@cjr.nz>
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
Steve French <stfrench@microsoft.com>
Subject: [cifs:for-next 8/8] fs/cifs/dfs_cache.c:1294:2: warning: variable 'ppath' is used uninitialized whenever 'if' condition is false
Date: Sat, 4 Jun 2022 13:00:31 +0800 [thread overview]
Message-ID: <202206041223.Kx81JSQt-lkp@intel.com> (raw)
tree: git://git.samba.org/sfrench/cifs-2.6.git for-next
head: ef605e86821253d16d47a02ce1f766a461614fef
commit: ef605e86821253d16d47a02ce1f766a461614fef [8/8] cifs: skip trailing separators of prefix paths
config: arm-randconfig-c002-20220603 (https://download.01.org/0day-ci/archive/20220604/202206041223.Kx81JSQt-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project b364c76683f8ef241025a9556300778c07b590c2)
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
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
git remote add cifs git://git.samba.org/sfrench/cifs-2.6.git
git fetch --no-tags cifs for-next
git checkout ef605e86821253d16d47a02ce1f766a461614fef
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash fs/cifs/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> fs/cifs/dfs_cache.c:1294:2: warning: variable 'ppath' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (target_pplen || dfsref_pplen) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:56:28: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:58:30: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/cifs/dfs_cache.c:1307:12: note: uninitialized use occurs here
*prefix = ppath;
^~~~~
fs/cifs/dfs_cache.c:1294:2: note: remove the 'if' if its condition is always true
if (target_pplen || dfsref_pplen) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:56:23: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^
fs/cifs/dfs_cache.c:1270:28: note: initialize the variable 'ppath' to silence this warning
char *target_share, *ppath;
^
= NULL
1 warning generated.
vim +1294 fs/cifs/dfs_cache.c
1255
1256 /**
1257 * dfs_cache_get_tgt_share - parse a DFS target
1258 *
1259 * @path: DFS full path
1260 * @it: DFS target iterator.
1261 * @share: tree name.
1262 * @prefix: prefix path.
1263 *
1264 * Return zero if target was parsed correctly, otherwise non-zero.
1265 */
1266 int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **share,
1267 char **prefix)
1268 {
1269 char sep;
1270 char *target_share, *ppath;
1271 const char *target_ppath, *dfsref_ppath;
1272 size_t target_pplen, dfsref_pplen;
1273 size_t len, c;
1274
1275 if (!it || !path || !share || !prefix || strlen(path) < it->it_path_consumed)
1276 return -EINVAL;
1277
1278 sep = it->it_name[0];
1279 if (sep != '\\' && sep != '/')
1280 return -EINVAL;
1281
1282 target_ppath = parse_target_share(it->it_name, &target_share);
1283 if (IS_ERR(target_ppath))
1284 return PTR_ERR(target_ppath);
1285
1286 /* point to prefix in DFS referral path */
1287 dfsref_ppath = path + it->it_path_consumed;
1288 dfsref_ppath += strspn(dfsref_ppath, "/\\");
1289
1290 target_pplen = strlen(target_ppath);
1291 dfsref_pplen = strlen(dfsref_ppath);
1292
1293 /* merge prefix paths from DFS referral path and target node */
> 1294 if (target_pplen || dfsref_pplen) {
1295 len = target_pplen + dfsref_pplen + 2;
1296 ppath = kzalloc(len, GFP_KERNEL);
1297 if (!ppath) {
1298 kfree(target_share);
1299 return -ENOMEM;
1300 }
1301 c = strscpy(ppath, target_ppath, len);
1302 if (c && dfsref_pplen)
1303 ppath[c] = sep;
1304 strlcat(ppath, dfsref_ppath, len);
1305 }
1306 *share = target_share;
1307 *prefix = ppath;
1308 return 0;
1309 }
1310
--
0-DAY CI Kernel Test Service
https://01.org/lkp
reply other threads:[~2022-06-04 5:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=202206041223.Kx81JSQt-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-cifs@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=pc@cjr.nz \
--cc=samba-technical@lists.samba.org \
--cc=stfrench@microsoft.com \
/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