From c45360d4633850839bb9c2d77dbf8a8285e9ad49 Mon Sep 17 00:00:00 2001 From: Marian Klymov Date: Sat, 2 Jun 2018 23:52:56 +0300 Subject: cppcheck: fix warnings - Get rid of variable that was generating false positive warning (unitialized) - Fix issues in tests - Reduce scope of several variables all over etc Closes #2631 --- tests/server/tftpd.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'tests/server/tftpd.c') diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index a8b565197..c00731fa2 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -955,8 +955,6 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size) int first = 1, ecode; struct formats *pf; char *filename, *mode = NULL; - int error; - FILE *server; #ifdef USE_WINSOCK DWORD recvtimeout, recvtimeoutbak; #endif @@ -964,9 +962,9 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size) int toggle = 1; /* Open request dump file. */ - server = fopen(REQUEST_DUMP, "ab"); + FILE *server = fopen(REQUEST_DUMP, "ab"); if(!server) { - error = errno; + int error = errno; logmsg("fopen() failed with error: %d %s", error, strerror(error)); logmsg("Error opening file: %s", REQUEST_DUMP); return -1; @@ -1138,9 +1136,6 @@ static int validate_access(struct testcase *test, const char *filename, int mode) { char *ptr; - long testno, partno; - int error; - char partbuf[80]="data"; logmsg("trying to get file: %s mode %x", filename, mode); @@ -1161,6 +1156,9 @@ static int validate_access(struct testcase *test, ptr = strrchr(filename, '/'); if(ptr) { + char partbuf[80]="data"; + long partno; + long testno; char *file; ptr++; /* skip the slash */ @@ -1194,7 +1192,7 @@ static int validate_access(struct testcase *test, if(file) { FILE *stream = fopen(file, "rb"); if(!stream) { - error = errno; + int error = errno; logmsg("fopen() failed with error: %d %s", error, strerror(error)); logmsg("Error opening file: %s", file); logmsg("Couldn't open test file: %s", file); @@ -1202,7 +1200,7 @@ static int validate_access(struct testcase *test, } else { size_t count; - error = getpart(&test->buffer, &count, "reply", partbuf, stream); + int error = getpart(&test->buffer, &count, "reply", partbuf, stream); fclose(stream); if(error) { logmsg("getpart() failed with error: %d", error); -- cgit v1.2.3