From: Paul Eggert Date: Fri, 26 Mar 2021 21:06:26 +0000 (-0700) Subject: env: remove asserts X-Git-Tag: v9.0~133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52f11d8b7ce886fd85b933eac58a62ee90ec63ce;p=thirdparty%2Fcoreutils.git env: remove asserts The assertions didn’t help catch the most recent bug which was in their area, and kind of get in the way. * src/env.c: Do not include , and remove all assertions. These seem to have been put in to pacify gcov, but surely there’s a better way. (escape_char): Pacify GCC with 'assume' instead. --- diff --git a/src/env.c b/src/env.c index e13a312cdd..262c02852a 100644 --- a/src/env.c +++ b/src/env.c @@ -23,7 +23,6 @@ #include #include -#include #include "system.h" #include "die.h" #include "error.h" @@ -210,7 +209,7 @@ escape_char (const char c) case 'r': return '\r'; case 't': return '\t'; case 'v': return '\v'; - default: assert (0); /* LCOV_EXCL_LINE */ + default: assume (false); } } @@ -221,7 +220,6 @@ escape_char (const char c) static const char* _GL_ATTRIBUTE_PURE scan_varname (const char* str) { - assert (str && *str == '$'); /* LCOV_EXCL_LINE */ if ( *(str+1) == '{' && (c_isalpha (*(str+2)) || *(str+2) == '_')) { const char* end = str+3; @@ -280,8 +278,6 @@ validate_split_str (const char* str, size_t* /*out*/ bufsize, size_t buflen; int cnt = 1; - assert (str && str[0] && !c_isspace (str[0])); /* LCOV_EXCL_LINE */ - dq = sq = sp = false; buflen = strlen (str)+1; @@ -303,12 +299,10 @@ validate_split_str (const char* str, size_t* /*out*/ bufsize, switch (*str) { case '\'': - assert (!(sq && dq)); /* LCOV_EXCL_LINE */ sq = !sq && !dq; break; case '"': - assert (!(sq && dq)); /* LCOV_EXCL_LINE */ dq = !sq && !dq; break; @@ -395,8 +389,6 @@ build_argv (const char* str, int extra_argc) } \ } while (0) - assert (str && str[0] && !c_isspace (str[0])); /* LCOV_EXCL_LINE */ - validate_split_str (str, &buflen, &newargc); /* allocate buffer. +6 for the "DUMMY\0" executable name, +1 for NUL. */ @@ -486,7 +478,6 @@ build_argv (const char* str, int extra_argc) /* Store the ${VARNAME} value. */ { char *n = extract_varname (str); - assert (n); /* ${VARNAME} already validated. */ char *v = getenv (n); if (v) {