linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] init/do_mounts: fix a coding style error
@ 2020-07-14  7:02 zhouchuangao
  2020-07-26 17:21 ` Al Viro
  0 siblings, 1 reply; 4+ messages in thread
From: zhouchuangao @ 2020-07-14  7:02 UTC (permalink / raw)
  To: viro; +Cc: linux, pc, axboe, dhowells, linux-kernel, zhouchuangao

Fix code style errors reported by scripts/checkpatch.pl.

Signed-off-by: zhouchuangao <zhouchuangao@xiaomi.com>
---
 init/do_mounts.c | 55 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/init/do_mounts.c b/init/do_mounts.c
index 29d326b..89bf389 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -101,7 +101,8 @@ static int match_dev_by_uuid(struct device *dev, const void *data)
  * by filesystem UUIDs.
  *
  * If @uuid_str is followed by a "/PARTNROFF=%d", then the number will be
- * extracted and used as an offset from the partition identified by the UUID.
+ * extracted and used as an offset from the partition identified by the
+ * UUID.
  *
  * Returns the matching dev_t on success or 0 on failure.
  */
@@ -249,7 +250,7 @@ dev_t name_to_dev_t(const char *name)
 #endif
 
 	if (strncmp(name, "/dev/", 5) != 0) {
-		unsigned maj, min, offset;
+		unsigned int maj, min, offset;
 		char dummy;
 
 		if ((sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) ||
@@ -412,8 +413,7 @@ static int __init do_mount_root(const char *name, const char *fs,
 	ksys_chdir("/root");
 	s = current->fs->pwd.dentry->d_sb;
 	ROOT_DEV = s->s_dev;
-	printk(KERN_INFO
-	       "VFS: Mounted root (%s filesystem)%s on device %u:%u.\n",
+	pr_info("VFS: Mounted root (%s filesystem)%s on device %u:%u.\n",
 	       s->s_type->name,
 	       sb_rdonly(s) ? " readonly" : "",
 	       MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
@@ -438,24 +438,25 @@ void __init mount_block_root(char *name, int flags)
 	for (p = fs_names; *p; p += strlen(p)+1) {
 		int err = do_mount_root(name, p, flags, root_mount_data);
 		switch (err) {
-			case 0:
-				goto out;
-			case -EACCES:
-			case -EINVAL:
-				continue;
+		case 0:
+			goto out;
+		case -EACCES:
+		case -EINVAL:
+			continue;
 		}
-	        /*
+		/*
 		 * Allow the user to distinguish between failed sys_open
 		 * and bad superblock on root device.
 		 * and give them a list of the available devices
 		 */
-		printk("VFS: Cannot open root device \"%s\" or %s: error %d\n",
+		pr_info("VFS: Cannot open root device \"%s\" or %s: error %d\n",
 				root_device_name, b, err);
-		printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");
+		pr_info("Please append a correct \"root=\" boot option; "
+			"here are the available partitions:\n");
 
 		printk_all_partitions();
 #ifdef CONFIG_DEBUG_BLOCK_EXT_DEVT
-		printk("DEBUG_BLOCK_EXT_DEVT is enabled, you need to specify "
+		pr_info("DEBUG_BLOCK_EXT_DEVT is enabled, you need to specify "
 		       "explicit textual name for \"root=\" boot option.\n");
 #endif
 		panic("VFS: Unable to mount root fs on %s", b);
@@ -465,17 +466,17 @@ void __init mount_block_root(char *name, int flags)
 		goto retry;
 	}
 
-	printk("List of all partitions:\n");
+	pr_info("List of all partitions:\n");
 	printk_all_partitions();
-	printk("No filesystem could mount root, tried: ");
+	pr_info("No filesystem could mount root, tried: ");
 	for (p = fs_names; *p; p += strlen(p)+1)
-		printk(" %s", p);
-	printk("\n");
+		pr_info(" %s", p);
+	pr_info("\n");
 	panic("VFS: Unable to mount root fs on %s", b);
 out:
 	put_page(page);
 }
- 
+
 #ifdef CONFIG_ROOT_NFS
 
 #define NFSROOT_TIMEOUT_MIN	5
@@ -560,6 +561,7 @@ void __init change_floppy(char *fmt, ...)
 	char c;
 	int fd;
 	va_list args;
+
 	va_start(args, fmt);
 	vsprintf(buf, fmt, args);
 	va_end(args);
@@ -568,7 +570,7 @@ void __init change_floppy(char *fmt, ...)
 		ksys_ioctl(fd, FDEJECT, 0);
 		ksys_close(fd);
 	}
-	printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
+	pr_notice("VFS: Insert %s and press ENTER\n", buf);
 	fd = ksys_open("/dev/console", O_RDWR, 0);
 	if (fd >= 0) {
 		ksys_ioctl(fd, TCGETS, (long)&termios);
@@ -585,27 +587,27 @@ void __init change_floppy(char *fmt, ...)
 void __init mount_root(void)
 {
 #ifdef CONFIG_ROOT_NFS
-	if (ROOT_DEV == Root_NFS) {
+	if (Root_NFS == ROOT_DEV) {
 		if (mount_nfs_root())
 			return;
 
-		printk(KERN_ERR "VFS: Unable to mount root fs via NFS, trying floppy.\n");
+		pr_err("VFS: Unable to mount root fs via NFS, trying floppy.\n");
 		ROOT_DEV = Root_FD0;
 	}
 #endif
 #ifdef CONFIG_CIFS_ROOT
-	if (ROOT_DEV == Root_CIFS) {
+	if (Root_CIFS == ROOT_DEV) {
 		if (mount_cifs_root())
 			return;
 
-		printk(KERN_ERR "VFS: Unable to mount root fs via SMB, trying floppy.\n");
+		pr_err("VFS: Unable to mount root fs via SMB, trying floppy.\n");
 		ROOT_DEV = Root_FD0;
 	}
 #endif
 #ifdef CONFIG_BLK_DEV_FD
 	if (MAJOR(ROOT_DEV) == FLOPPY_MAJOR) {
 		/* rd_doload is 2 for a dual initrd/ramload setup */
-		if (rd_doload==2) {
+		if (rd_doload == 2) {
 			if (rd_load_disk(1)) {
 				ROOT_DEV = Root_RAM1;
 				root_device_name = NULL;
@@ -633,7 +635,7 @@ void __init prepare_namespace(void)
 	int is_floppy;
 
 	if (root_delay) {
-		printk(KERN_INFO "Waiting %d sec before mounting root device...\n",
+		pr_info("Waiting %d sec before mounting root device...\n",
 		       root_delay);
 		ssleep(root_delay);
 	}
@@ -666,8 +668,7 @@ void __init prepare_namespace(void)
 
 	/* wait for any asynchronous scanning to complete */
 	if ((ROOT_DEV == 0) && root_wait) {
-		printk(KERN_INFO "Waiting for root device %s...\n",
-			saved_root_name);
+		pr_info("Waiting for root device %s...\n", saved_root_name);
 		while (driver_probe_done() != 0 ||
 			(ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
 			msleep(5);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] init/do_mounts: fix a coding style error
  2020-07-14  7:02 [PATCH] init/do_mounts: fix a coding style error zhouchuangao
@ 2020-07-26 17:21 ` Al Viro
  2020-07-26 17:50   ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2020-07-26 17:21 UTC (permalink / raw)
  To: zhouchuangao; +Cc: linux, pc, axboe, dhowells, linux-kernel, zhouchuangao

On Tue, Jul 14, 2020 at 03:02:58PM +0800, zhouchuangao wrote:
> Fix code style errors reported by scripts/checkpatch.pl.

NAKed-because: excessive deference to checkpatch.pl

It's not a holy oracle than needs to be appeased, no questions
asked.  Reference to it is absolutely insufficient reason for
_anything_ - in effect your commit message could've been
"just because" for all the information it contains.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] init/do_mounts: fix a coding style error
  2020-07-26 17:21 ` Al Viro
@ 2020-07-26 17:50   ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2020-07-26 17:50 UTC (permalink / raw)
  To: Al Viro, zhouchuangao
  Cc: linux, pc, axboe, dhowells, linux-kernel, zhouchuangao

On Sun, 2020-07-26 at 18:21 +0100, Al Viro wrote:
> On Tue, Jul 14, 2020 at 03:02:58PM +0800, zhouchuangao wrote:
> > Fix code style errors reported by scripts/checkpatch.pl.
> 
> NAKed-because: excessive deference to checkpatch.pl
> 
> It's not a holy oracle than needs to be appeased, no questions
> asked.  Reference to it is absolutely insufficient reason for
> _anything_ - in effect your commit message could've been
> "just because" for all the information it contains.

Al is right.

Something that could useful is to avoid using printks without
a KERN_<LEVEL> or add KERN_CONT to some continuation printks.

Maybe:
---
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 4f4ceb358055..3f37d859cf2a 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -468,8 +468,8 @@ void __init mount_block_root(char *name, int flags)
 	printk_all_partitions();
 	printk("No filesystem could mount root, tried: ");
 	for (p = fs_names; *p; p += strlen(p)+1)
-		printk(" %s", p);
-	printk("\n");
+		pr_cont(" %s", p);
+	pr_cont("\n");
 	panic("VFS: Unable to mount root fs on %s", b);
 out:
 	put_page(page);



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] init/do_mounts: fix a coding style error
@ 2020-05-21  3:41 zhouchuangao
  0 siblings, 0 replies; 4+ messages in thread
From: zhouchuangao @ 2020-05-21  3:41 UTC (permalink / raw)
  To: viro; +Cc: linux, zhouchuangao, tytso, davem, pc, dhowells, linux-kernel

Fix code style errors reported by scripts/checkpatch.pl.

Signed-off-by: zhouchuangao <zhouchuangao@xiaomi.com>
---
 init/do_mounts.c | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/init/do_mounts.c b/init/do_mounts.c
index 29d326b..2f8bd41 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -249,7 +249,7 @@ dev_t name_to_dev_t(const char *name)
 #endif
 
 	if (strncmp(name, "/dev/", 5) != 0) {
-		unsigned maj, min, offset;
+		unsigned int maj, min, offset;
 		char dummy;
 
 		if ((sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) ||
@@ -412,8 +412,7 @@ static int __init do_mount_root(const char *name, const char *fs,
 	ksys_chdir("/root");
 	s = current->fs->pwd.dentry->d_sb;
 	ROOT_DEV = s->s_dev;
-	printk(KERN_INFO
-	       "VFS: Mounted root (%s filesystem)%s on device %u:%u.\n",
+	pr_info("VFS: Mounted root (%s filesystem)%s on device %u:%u.\n",
 	       s->s_type->name,
 	       sb_rdonly(s) ? " readonly" : "",
 	       MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
@@ -437,25 +436,26 @@ void __init mount_block_root(char *name, int flags)
 retry:
 	for (p = fs_names; *p; p += strlen(p)+1) {
 		int err = do_mount_root(name, p, flags, root_mount_data);
+
 		switch (err) {
-			case 0:
-				goto out;
-			case -EACCES:
-			case -EINVAL:
-				continue;
+		case 0:
+			goto out;
+		case -EACCES:
+		case -EINVAL:
+			continue;
 		}
-	        /*
+		/*
 		 * Allow the user to distinguish between failed sys_open
 		 * and bad superblock on root device.
 		 * and give them a list of the available devices
 		 */
-		printk("VFS: Cannot open root device \"%s\" or %s: error %d\n",
+		pr_info("VFS: Cannot open root device \"%s\" or %s: error %d\n",
 				root_device_name, b, err);
-		printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");
+		pr_info("Please append a correct \"root=\" boot option; here are the available partitions:\n");
 
 		printk_all_partitions();
 #ifdef CONFIG_DEBUG_BLOCK_EXT_DEVT
-		printk("DEBUG_BLOCK_EXT_DEVT is enabled, you need to specify "
+		pr_info("DEBUG_BLOCK_EXT_DEVT is enabled, you need to specify "
 		       "explicit textual name for \"root=\" boot option.\n");
 #endif
 		panic("VFS: Unable to mount root fs on %s", b);
@@ -465,17 +465,17 @@ void __init mount_block_root(char *name, int flags)
 		goto retry;
 	}
 
-	printk("List of all partitions:\n");
+	pr_info("List of all partitions:\n");
 	printk_all_partitions();
-	printk("No filesystem could mount root, tried: ");
+	pr_info("No filesystem could mount root, tried: ");
 	for (p = fs_names; *p; p += strlen(p)+1)
-		printk(" %s", p);
-	printk("\n");
+		pr_info(" %s", p);
+	pr_info("\n");
 	panic("VFS: Unable to mount root fs on %s", b);
 out:
 	put_page(page);
 }
- 
+
 #ifdef CONFIG_ROOT_NFS
 
 #define NFSROOT_TIMEOUT_MIN	5
@@ -560,6 +560,7 @@ void __init change_floppy(char *fmt, ...)
 	char c;
 	int fd;
 	va_list args;
+
 	va_start(args, fmt);
 	vsprintf(buf, fmt, args);
 	va_end(args);
@@ -568,7 +569,7 @@ void __init change_floppy(char *fmt, ...)
 		ksys_ioctl(fd, FDEJECT, 0);
 		ksys_close(fd);
 	}
-	printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
+	pr_notice("VFS: Insert %s and press ENTER\n", buf);
 	fd = ksys_open("/dev/console", O_RDWR, 0);
 	if (fd >= 0) {
 		ksys_ioctl(fd, TCGETS, (long)&termios);
@@ -585,27 +586,27 @@ void __init change_floppy(char *fmt, ...)
 void __init mount_root(void)
 {
 #ifdef CONFIG_ROOT_NFS
-	if (ROOT_DEV == Root_NFS) {
+	if (Root_NFS == ROOT_DEV) {
 		if (mount_nfs_root())
 			return;
 
-		printk(KERN_ERR "VFS: Unable to mount root fs via NFS, trying floppy.\n");
+		pr_err("VFS: Unable to mount root fs via NFS, trying floppy.\n");
 		ROOT_DEV = Root_FD0;
 	}
 #endif
 #ifdef CONFIG_CIFS_ROOT
-	if (ROOT_DEV == Root_CIFS) {
+	if (Root_CIFS == ROOT_DEV) {
 		if (mount_cifs_root())
 			return;
 
-		printk(KERN_ERR "VFS: Unable to mount root fs via SMB, trying floppy.\n");
+		pr_err("VFS: Unable to mount root fs via SMB, trying floppy.\n");
 		ROOT_DEV = Root_FD0;
 	}
 #endif
 #ifdef CONFIG_BLK_DEV_FD
 	if (MAJOR(ROOT_DEV) == FLOPPY_MAJOR) {
 		/* rd_doload is 2 for a dual initrd/ramload setup */
-		if (rd_doload==2) {
+		if (rd_doload == 2) {
 			if (rd_load_disk(1)) {
 				ROOT_DEV = Root_RAM1;
 				root_device_name = NULL;
@@ -633,7 +634,7 @@ void __init prepare_namespace(void)
 	int is_floppy;
 
 	if (root_delay) {
-		printk(KERN_INFO "Waiting %d sec before mounting root device...\n",
+		pr_info("Waiting %d sec before mounting root device...\n",
 		       root_delay);
 		ssleep(root_delay);
 	}
@@ -666,8 +667,7 @@ void __init prepare_namespace(void)
 
 	/* wait for any asynchronous scanning to complete */
 	if ((ROOT_DEV == 0) && root_wait) {
-		printk(KERN_INFO "Waiting for root device %s...\n",
-			saved_root_name);
+		pr_info("Waiting for root device %s...\n", saved_root_name);
 		while (driver_probe_done() != 0 ||
 			(ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
 			msleep(5);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-26 17:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14  7:02 [PATCH] init/do_mounts: fix a coding style error zhouchuangao
2020-07-26 17:21 ` Al Viro
2020-07-26 17:50   ` Joe Perches
  -- strict thread matches above, loose matches on Subject: below --
2020-05-21  3:41 zhouchuangao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).