lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / util-linux / readprofile.c
index cac5fa4a136b0495a6c42deb8a4dda9b947dc367..00b3382d850a77626df0bc1c4b28085509ac1945 100644 (file)
@@ -4,7 +4,7 @@
  *
  *  Copyright (C) 1994,1996 Alessandro Rubini (rubini@ipvvis.unipv.it)
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 /*
@@ -42,7 +42,7 @@ static const char defaultmap[] ALIGN1 = "/boot/System.map";
 static const char defaultpro[] ALIGN1 = "/proc/profile";
 
 int readprofile_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int readprofile_main(int argc ATTRIBUTE_UNUSED, char **argv)
+int readprofile_main(int argc UNUSED_PARAM, char **argv)
 {
        FILE *map;
        const char *mapFile, *proFile;
@@ -144,7 +144,7 @@ int readprofile_main(int argc ATTRIBUTE_UNUSED, char **argv)
 
        total = 0;
 
-       map = xfopen(mapFile, "r");
+       map = xfopen_for_read(mapFile);
 
        while (fgets(mapline, S_LEN, map)) {
                if (sscanf(mapline, "%llx %s %s", &fn_add, mode, fn_name) != 3)
@@ -176,9 +176,11 @@ int readprofile_main(int argc ATTRIBUTE_UNUSED, char **argv)
                /* ignore any LEADING (before a '[tT]' symbol is found)
                   Absolute symbols */
                if ((*mode == 'A' || *mode == '?') && total == 0) continue;
-               if (*mode != 'T' && *mode != 't' &&
-                   *mode != 'W' && *mode != 'w')
+               if (*mode != 'T' && *mode != 't'
+                && *mode != 'W' && *mode != 'w'
+               ) {
                        break;  /* only text is profiled */
+               }
 
                if (indx >= len / sizeof(*buf))
                        bb_error_msg_and_die("profile address out of range. "