perf probe: Clean up redundant tests in show_line_range()
authorFranck Bui-Huu <fbuihuu@gmail.com>
Mon, 20 Dec 2010 14:18:02 +0000 (15:18 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 21 Dec 2010 18:20:12 +0000 (16:20 -0200)
It also removes some superflous parentheses.

Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1292854685-8230-4-git-send-email-fbuihuu@gmail.com>
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/probe-event.c

index 327604c1253f34460cfc9630a5f30b6a444e16e5..b812f1412c3ad8101cb417a9aef2b576b6302457 100644 (file)
@@ -373,26 +373,30 @@ int show_line_range(struct line_range *lr, const char *module)
                return -errno;
        }
        /* Skip to starting line number */
-       while (l < lr->start && ret >= 0)
+       while (l < lr->start) {
                ret = show_one_line(fp, l++, true, false);
-       if (ret < 0)
-               goto end;
+               if (ret < 0)
+                       goto end;
+       }
 
        list_for_each_entry(ln, &lr->line_list, list) {
-               while (ln->line > l && ret >= 0)
-                       ret = show_one_line(fp, (l++) - lr->offset,
-                                           false, false);
-               if (ret >= 0)
-                       ret = show_one_line(fp, (l++) - lr->offset,
-                                           false, true);
+               for (; ln->line > l; l++) {
+                       ret = show_one_line(fp, l - lr->offset, false, false);
+                       if (ret < 0)
+                               goto end;
+               }
+               ret = show_one_line(fp, l++ - lr->offset, false, true);
                if (ret < 0)
                        goto end;
        }
 
        if (lr->end == INT_MAX)
                lr->end = l + NR_ADDITIONAL_LINES;
-       while (l <= lr->end && !feof(fp) && ret >= 0)
-               ret = show_one_line(fp, (l++) - lr->offset, false, false);
+       while (l <= lr->end && !feof(fp)) {
+               ret = show_one_line(fp, l++ - lr->offset, false, false);
+               if (ret < 0)
+                       break;
+       }
 end:
        fclose(fp);
        return ret;