Skip to contentSkip to conversation

scripts/kallsyms build warning fix

PATCH In review Himanshu Chauhan 2 participants 3 messages Jan 25, 2010 – Jan 26, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/kallsyms build warning fix

Hi all,

This is a small patch that fixes the build warning of scripts/kallsyms.c

Regards
Himanshu

---
 scripts/kallsyms.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
scripts/kallsyms.c +4 -2
index 86c3896..e3902fb 100644
@@ -108,8 +108,10 @@ static int read_symbol(FILE *in, struct sym_entry *s)
 	rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str);
 	if (rc != 3) {
 		if (rc != EOF) {
-			/* skip line */
-			fgets(str, 500, in);
+			/* skip line. sym is used as dummy to
+			 * shut of "warn_unused_result" warning.
+			 */
+			sym = fgets(str, 500, in);
 		}
 		return -1;
 	}
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 20 lines · Himanshu Chauhan

Hi all,

This is a small patch that fixes the build warning of scripts/kallsyms.c

Regards
Himanshu

---
 scripts/kallsyms.c |    6 ++++--

 1 files changed, 4 insertions(+), 2 deletions(-)
scripts/kallsyms.c +0 -0
index 86c3896..e3902fb 100644
@@ -108,8 +108,10 @@ static int read_symbol(FILE *in, struct sym_entry *s)
        rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str);
        if (rc != 3) {

scripts/kallsyms.c static int read_symbol(FILE *in, struct sym_entry *s) · line 117

Quoted 10 lines
scripts/kallsyms.c +4 -2
                if (rc != EOF) {
-                       /* skip line */
-                       fgets(str, 500, in);
+                       /* skip line. sym is used as dummy to
+                        * shut of "warn_unused_result" warning.
+                        */
+                       sym = fgets(str, 500, in);
                }
                return -1;
        }

Why not use the return value to do some useful checking?

#2 lore raw
Quoted 26 lines · Américo Wang
Quoted 24 lines · Himanshu Chauhan

Hi all,

This is a small patch that fixes the build warning of scripts/kallsyms.c

Regards
Himanshu

---
 scripts/kallsyms.c |    6 ++++--

 1 files changed, 4 insertions(+), 2 deletions(-)
scripts/kallsyms.c +1 -2
index 86c3896..e3902fb 100644
@@ -108,8 +108,10 @@ static int read_symbol(FILE *in, struct sym_entry *s)
        rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str);
        if (rc != 3) {
                if (rc != EOF) {
-                       /* skip line */
-                       fgets(str, 500, in);
+                       /* skip line. sym is used as dummy to
Quoted 8 lines

scripts/kallsyms.c static int read_symbol(FILE *in, struct sym_entry *s) · line 117

Quoted 6 lines
scripts/kallsyms.c +3 -0
+                        * shut of "warn_unused_result" warning.
+                        */
+                       sym = fgets(str, 500, in);
                }
                return -1;
        }

Why not use the return value to do some useful checking?

fgets is called as a part of error handling. Its called just to drop a line and return immediately. read_map is reading the file in a loop and read_symbol reads line by line. So I think there is no point in using return value for useful checking. Other checks like 3 items were returned or !EOF have already been done.

Regards
Himanshu