diff mbox series

[1/3] cifs: introduce smb3_options_for_each() helper

Message ID 20210511163609.11019-2-pc@cjr.nz
State New
Headers show
Series Support multiple ips per hostname | expand

Commit Message

Paulo Alcantara May 11, 2021, 4:36 p.m. UTC
Introduce a new helper to walk through the mount options and avoid
duplicating it all over the cifs code.

Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
---
 fs/cifs/cifsglob.h | 16 ++++++++++++++++
 fs/cifs/misc.c     | 48 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

Comments

kernel test robot May 11, 2021, 6:15 p.m. UTC | #1
Hi Paulo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on cifs/for-next]
[also build test WARNING on v5.13-rc1 next-20210511]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Paulo-Alcantara/Support-multiple-ips-per-hostname/20210512-003751
base:   git://git.samba.org/sfrench/cifs-2.6.git for-next
config: microblaze-randconfig-s032-20210511 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/9d073f7c6b721cd2d1ed181b3ec7880bf421d689
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Paulo-Alcantara/Support-multiple-ips-per-hostname/20210512-003751
        git checkout 9d073f7c6b721cd2d1ed181b3ec7880bf421d689
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=microblaze 

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

   fs/cifs/misc.c:614: warning: Function parameter or member 'cfile' not described in 'cifs_queue_oplock_break'
   fs/cifs/misc.c:1017: warning: Function parameter or member 'name' not described in 'cifs_alloc_hash'
   fs/cifs/misc.c:1017: warning: Function parameter or member 'shash' not described in 'cifs_alloc_hash'
   fs/cifs/misc.c:1017: warning: Function parameter or member 'sdesc' not described in 'cifs_alloc_hash'
   fs/cifs/misc.c:1053: warning: Function parameter or member 'shash' not described in 'cifs_free_hash'
   fs/cifs/misc.c:1053: warning: Function parameter or member 'sdesc' not described in 'cifs_free_hash'
   fs/cifs/misc.c:1068: warning: Function parameter or member 'rqst' not described in 'rqst_page_get_length'
   fs/cifs/misc.c:1068: warning: Function parameter or member 'page' not described in 'rqst_page_get_length'
   fs/cifs/misc.c:1068: warning: Function parameter or member 'len' not described in 'rqst_page_get_length'
   fs/cifs/misc.c:1068: warning: Function parameter or member 'offset' not described in 'rqst_page_get_length'
   fs/cifs/misc.c:1101: warning: Function parameter or member 'dst' not described in 'copy_path_name'
   fs/cifs/misc.c:1101: warning: Function parameter or member 'src' not described in 'copy_path_name'
>> fs/cifs/misc.c:1289: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
    * Parse a string that is in key[=val][,key[=val]]* form.


vim +1289 fs/cifs/misc.c

  1287	
  1288	/**
> 1289	 * Parse a string that is in key[=val][,key[=val]]* form.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index ea90c53386b8..6c65e39f0509 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1960,4 +1960,20 @@  static inline bool is_tcon_dfs(struct cifs_tcon *tcon)
 		tcon->share_flags & (SHI1005_FLAGS_DFS | SHI1005_FLAGS_DFS_ROOT);
 }
 
+char *smb3_parse_option(char *options, char sep, char **nkey, char **nval);
+
+static inline char *smb3_parse_options_sep(char *options, char *sep, char **nkey, char **nval)
+{
+	*sep = ',';
+	if (!strncmp(options, "sep=", 4)) {
+		*sep = options[4];
+		options += 5;
+	}
+	return smb3_parse_option(options, *sep, nkey, nval);
+}
+
+#define smb3_options_for_each(opts, nopts, sep, key, val) \
+	for (nopts = (opts), nopts = smb3_parse_options_sep(nopts, &sep, &(key), &(val)); \
+	     (key); nopts = smb3_parse_option(nopts, sep, &(key), &(val)))
+
 #endif	/* _CIFS_GLOB_H */
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index cd705f8a4e31..7b3b1ea76baf 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -1284,3 +1284,51 @@  int update_super_prepath(struct cifs_tcon *tcon, char *prefix)
 	cifs_put_tcon_super(sb);
 	return rc;
 }
+
+/**
+ * Parse a string that is in key[=val][,key[=val]]* form.
+ *
+ * @options: The options to parse
+ * @sep: The options separator
+ * @nkey: The next key pointer
+ * @nval: The next value pointer
+ *
+ * Returns next key-value pair to be parsed, otherwise NULL.
+ */
+char *smb3_parse_option(char *options, char sep, char **nkey, char **nval)
+{
+	char *key, *value;
+	char sepstr[2] = {sep, '\0'};
+
+	*nkey = NULL;
+	*nval = NULL;
+
+	if (!options || !options[0])
+		return NULL;
+
+	while ((key = strsep(&options, sepstr)) != NULL) {
+		size_t len;
+
+		if (*key == 0)
+			return NULL;
+
+		while (options && options[0] == sep) {
+			len = strlen(key);
+			strcpy(key + len, options);
+			options = strchr(options, sep);
+			if (options)
+				*options++ = 0;
+		}
+
+		value = strchr(key, '=');
+		if (value) {
+			if (value == key)
+				continue;
+			*value++ = 0;
+		}
+		break;
+	}
+	*nkey = key;
+	*nval = value;
+	return options;
+}