summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fenkart <andreas.fenkart@digitalstrom.com>2016-03-11 09:39:38 +0100
committerTom Rini <trini@konsulko.com>2016-03-26 18:49:29 -0400
commit69067a34b1ab1fb14f0183acb85358db60aac484 (patch)
tree4c252a4c95244a1664cc525562e5e7f1069ae17d
parent938c29ff41b40a1b6cafc9bcc81b89ad2bd537ba (diff)
downloadu-boot-imx-69067a34b1ab1fb14f0183acb85358db60aac484.zip
u-boot-imx-69067a34b1ab1fb14f0183acb85358db60aac484.tar.gz
u-boot-imx-69067a34b1ab1fb14f0183acb85358db60aac484.tar.bz2
tools: env: fw_parse_script: simplify removal of newline/carriage return
fgets returns when the first '\n' is found Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
-rw-r--r--tools/env/fw_env.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 60574f2..5c7505c 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -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;
/*