]> Git Repo - J-u-boot.git/commitdiff
tools: env: fw_parse_script: simplify removal of newline/carriage return
authorAndreas Fenkart <[email protected]>
Fri, 11 Mar 2016 08:39:38 +0000 (09:39 +0100)
committerTom Rini <[email protected]>
Sat, 26 Mar 2016 22:49:29 +0000 (18:49 -0400)
fgets returns when the first '\n' is found

Signed-off-by: Andreas Fenkart <[email protected]>
tools/env/fw_env.c

index 60574f249d3daf37c922d37885ff79f808ff9716..5c7505c0fdcc7f20ac2d1b30e6c257a663797758 100644 (file)
@@ -566,14 +566,12 @@ int fw_parse_script(char *fname)
                }
 
                /* Drop ending line feed / carriage return */
-               while (len > 0 && (dump[len - 1] == '\n' ||
-                               dump[len - 1] == '\r')) {
-                       dump[len - 1] = '\0';
-                       len--;
-               }
+               dump[--len] = '\0';
+               if (len && dump[len - 1] == '\r')
+                       dump[--len] = '\0';
 
                /* Skip comment or empty lines */
-               if ((len == 0) || dump[0] == '#')
+               if (len == 0 || dump[0] == '#')
                        continue;
 
                /*
This page took 0.036371 seconds and 4 git commands to generate.