scripts/Kbuild.include: Fix portability problem of "echo -e"
[linux-2.6.git] / scripts / kallsyms.c
index 3cb5789..487ac6f 100644 (file)
@@ -107,10 +107,8 @@ 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);
-               }
+               if (rc != EOF && fgets(str, 500, in) == NULL)
+                       fprintf(stderr, "Read error or end of file.\n");
                return -1;
        }
 
@@ -167,11 +165,11 @@ static int symbol_valid_tr(struct sym_entry *s)
        for (i = 0; i < ARRAY_SIZE(text_ranges); ++i) {
                tr = &text_ranges[i];
 
-               if (s->addr >= tr->start && s->addr < tr->end)
-                       return 0;
+               if (s->addr >= tr->start && s->addr <= tr->end)
+                       return 1;
        }
 
-       return 1;
+       return 0;
 }
 
 static int symbol_valid(struct sym_entry *s)
@@ -502,6 +500,8 @@ static void optimize_result(void)
 
                        /* find the token with the breates profit value */
                        best = find_best_token();
+                       if (token_profit[best] == 0)
+                               break;
 
                        /* place it in the "best" table */
                        best_table_len[i] = 2;
@@ -585,7 +585,7 @@ static int prefix_underscores_count(const char *str)
 {
        const char *tail = str;
 
-       while (*tail != '_')
+       while (*tail == '_')
                tail++;
 
        return tail - str;