Skip to content

Commit

Permalink
sgw: fix EOL stripping of the egress file
Browse files Browse the repository at this point in the history
Fixes a Coverity warning

Signed-off-by: Ferry Huberts <[email protected]>
  • Loading branch information
fhuberts committed Oct 15, 2015
1 parent 1f26620 commit 9722e7b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/egressFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,9 @@ static bool readULL(const char * value, unsigned long long * valueNumber) {
* Strip EOL characters from the end of a string
*
* @param str the string to strip
* @param length the length of the string
*/
static void stripEols(char * str, ssize_t length) {
ssize_t len = length;
static void stripEols(char * str) {
ssize_t len = strlen(str);
while ((len > 0) && ((str[len - 1] == '\n') || (str[len - 1] == '\r'))) {
len--;
}
Expand Down Expand Up @@ -456,7 +455,6 @@ static bool readEgressFile(const char * fileName) {
unsigned int lineNumber = 0;

bool changed = false;
ssize_t length = -1;
bool reportedErrorsLocal = false;
const char * filepath = !fileName ? DEF_GW_EGRESS_FILE : fileName;

Expand Down Expand Up @@ -519,7 +517,7 @@ static bool readEgressFile(const char * fileName) {
memset(&network, 0, sizeof(network));
memset(&gateway, 0, sizeof(gateway));

stripEols(line, length);
stripEols(line);

memset(pmatch, 0, sizeof(pmatch));
if (regexec(&compiledRegexEgress, line, REGEX_EGRESS_LINE_MATCH_COUNT, pmatch, 0)) {
Expand Down

0 comments on commit 9722e7b

Please sign in to comment.