Skip to contentSkip to conversation

Staging: lustre: Removed unnecessary braces

PATCH Superseded aybuke ozdemir 2 participants 4 messages Feb 21, 2015 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Staging: lustre: Removed unnecessary braces

This patch fixes checkpatch.pl warning in llite_lib.c
WARNING: braces {} are not necessary for any arm of this statement

---
 drivers/staging/lustre/lustre/llite/llite_lib.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -3
index a3367bf..9646e1a 100644
@@ -87,11 +87,10 @@ static struct ll_sb_info *ll_init_sbi(void)
 
 	si_meminfo(&si);
 	pages = si.totalram - si.totalhigh;
-	if (pages >> (20 - PAGE_CACHE_SHIFT) < 512) {
+	if (pages >> (20 - PAGE_CACHE_SHIFT) < 512)
 		lru_page_max = pages / 2;
-	} else {
+	else
 		lru_page_max = (pages / 4) * 3;
-	}
 
 	/* initialize lru data */
 	atomic_set(&sbi->ll_cache.ccc_users, 0);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 Staging: lustre: use kstrtoul() instead of sscanf()

This patch makes checkpatch.pl by fixing the following warning:
WARNING: Prefer kstrto<type> to single variable sscanf

---
 drivers/staging/lustre/lustre/llite/llite_lib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/llite_lib.c +3 -1
index 9646e1a..62f923c 100644
@@ -2190,6 +2190,7 @@ int ll_process_config(struct lustre_cfg *lcfg)
 	struct lprocfs_static_vars lvars;
 	unsigned long x;
 	int rc = 0;
+	int rc1;
 
 	lprocfs_llite_init_vars(&lvars);
 
@@ -2197,7 +2198,8 @@ int ll_process_config(struct lustre_cfg *lcfg)
 	ptr = strrchr(lustre_cfg_string(lcfg, 0), '-');
 	if (!ptr || !*(++ptr))
 		return -EINVAL;
-	if (sscanf(ptr, "%lx", &x) != 1)
+	rc1 = kstrtoul(ptr, 16, &x);
+	if (rc1 != 1)
 		return -EINVAL;
 	sb = (void *)x;
 	/* This better be a real Lustre superblock! */
Signature · 1 line
1.9.1
#2 lore raw

Re: [Outreachy kernel] [PATCH 2/3] Staging: lustre: use kstrtoul() instead of sscanf()

Quoted 21 lines · aybuke ozdemir

This patch makes checkpatch.pl by fixing the following warning:
WARNING: Prefer kstrto<type> to single variable sscanf

---
 drivers/staging/lustre/lustre/llite/llite_lib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/llite_lib.c +1 -0
index 9646e1a..62f923c 100644
@@ -2190,6 +2190,7 @@ int ll_process_config(struct lustre_cfg *lcfg)
 	struct lprocfs_static_vars lvars;
 	unsigned long x;
 	int rc = 0;
+	int rc1;
 
 	lprocfs_llite_init_vars(&lvars);
 

drivers/staging/lustre/lustre/llite/llite_lib.c int ll_process_config(struct lustre_cfg *lcfg) · line 2202

Quoted 6 lines
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -1
@@ -2197,7 +2198,8 @@ int ll_process_config(struct lustre_cfg *lcfg)
 	ptr = strrchr(lustre_cfg_string(lcfg, 0), '-');
 	if (!ptr || !*(++ptr))
 		return -EINVAL;
-	if (sscanf(ptr, "%lx", &x) != 1)
+	rc1 = kstrtoul(ptr, 16, &x);
+	if (rc1 != 1)

It doesn't look like it is necessary to introduce rc1.

On the other hand, the documentation for kstrtoul says:

Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.

The function never returns 1, so you are not checking for errors in the right way.

julia

Quoted 13 lines
drivers/staging/lustre/lustre/llite/llite_lib.c +0 -1
 		return -EINVAL;
 	sb = (void *)x;
 	/* This better be a real Lustre superblock! */
--

1.9.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1424524553-9035-2-git-send-email-aybuke.147%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw

PATCH 3/3 Staging: lustre: Removed unnecessary spaces

In reply to aybuke ozdemir

Fix checkpatch.pl issues with "unnecessary whitespace before a quoted newline" in llite_lib.c

---
 drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/llite_lib.c +1 -1
index 62f923c..163bec0 100644
@@ -620,7 +620,7 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize)
 	rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_MAX_EASIZE),
 			  KEY_MAX_EASIZE, &size, lmmsize, NULL);
 	if (rc)
-		CERROR("Get max mdsize error rc %d \n", rc);
+		CERROR("Get max mdsize error rc %d\n", rc);
 
 	return rc;
 }
Signature · 1 line
1.9.1