From: Andreas Fenkart Date: Fri, 11 Mar 2016 08:39:38 +0000 (+0100) Subject: tools: env: fw_parse_script: simplify removal of newline/carriage return X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=69067a34b1ab1fb14f0183acb85358db60aac484;p=u-boot.git tools: env: fw_parse_script: simplify removal of newline/carriage return fgets returns when the first '\n' is found Signed-off-by: Andreas Fenkart --- diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 60574f249d..5c7505c0fd 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; /*