]> www.infradead.org Git - linux.git/commitdiff
bcachefs: Use strsep() in split_devs()
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 28 Sep 2023 04:50:27 +0000 (00:50 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:15 +0000 (17:10 -0400)
Minor refactoring to fix a smatch complaint.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs.c

index 73a3cebd734ff6536042bd00543534f605eab354..bc009ef497d0ff65a27ea853190310e0947d1b93 100644 (file)
@@ -1595,7 +1595,7 @@ static struct bch_fs *bch2_path_to_fs(const char *path)
 static char **split_devs(const char *_dev_name, unsigned *nr)
 {
        char *dev_name = NULL, **devs = NULL, *s;
-       size_t i, nr_devs = 0;
+       size_t i = 0, nr_devs = 0;
 
        dev_name = kstrdup(_dev_name, GFP_KERNEL);
        if (!dev_name)
@@ -1610,9 +1610,7 @@ static char **split_devs(const char *_dev_name, unsigned *nr)
                return NULL;
        }
 
-       for (i = 0, s = dev_name;
-            s;
-            (s = strchr(s, ':')) && (*s++ = '\0'))
+       while ((s = strsep(&dev_name, ":")))
                devs[i++] = s;
 
        *nr = nr_devs;