udpdump: fix issues from coverity.

Change-Id: I1d82d8166abe8eda6588ae2970ae9f2d096adf9d
Reviewed-on: https://code.wireshark.org/review/18198
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
This commit is contained in:
Dario Lombardo 2016-10-14 14:36:27 +02:00 committed by Jaap Keuter
parent fb9ce2796c
commit a19c12b4a9
1 changed files with 7 additions and 4 deletions

View File

@ -168,7 +168,7 @@ static int setup_dumpfile(const char* fifo, FILE** fp)
}
*fp = fopen(fifo, "w");
if (!fp) {
if (!(*fp)) {
g_warning("Error creating output file: %s", g_strerror(errno));
return EXIT_FAILURE;
}
@ -233,19 +233,22 @@ static int dump_packet(const char* proto_name, const guint16 listenport, const c
static void run_listener(const char* fifo, const guint16 port, const char* proto_name)
{
struct sockaddr_in clientaddr;
int clientlen;
int clientlen = 0;
socket_handle_t sock;
char buf[PKT_BUF_SIZE];
ssize_t buflen;
FILE* fp;
FILE* fp = NULL;
if (signal(SIGINT, exit_from_loop) == SIG_ERR) {
g_warning("Can't set signal handler");
return;
}
if (setup_dumpfile(fifo, &fp) == EXIT_FAILURE)
if (setup_dumpfile(fifo, &fp) == EXIT_FAILURE) {
if (fp)
fclose(fp);
return;
}
if (setup_listener(port, &sock) == EXIT_FAILURE)
return;