MinGW: Fix -Wformat

This commit is contained in:
João Valverde 2023-01-12 03:43:59 +00:00
parent 8cd74b7cd4
commit d902cabd3f
8 changed files with 27 additions and 27 deletions

View File

@ -419,7 +419,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
if (interface_opts->extcap_fifo != NULL) if (interface_opts->extcap_fifo != NULL)
{ {
#ifdef _WIN32 #ifdef _WIN32
char *pipe = ws_strdup_printf("%s%" PRIuPTR, EXTCAP_PIPE_PREFIX, interface_opts->extcap_pipe_h); char *pipe = ws_strdup_printf("%s%" PRIuMAX, EXTCAP_PIPE_PREFIX, (uintmax_t)interface_opts->extcap_pipe_h);
argv = sync_pipe_add_arg(argv, &argc, pipe); argv = sync_pipe_add_arg(argv, &argc, pipe);
g_free(pipe); g_free(pipe);
i_handles++; i_handles++;
@ -519,7 +519,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
#ifndef DEBUG_CHILD #ifndef DEBUG_CHILD
argv = sync_pipe_add_arg(argv, &argc, "-Z"); argv = sync_pipe_add_arg(argv, &argc, "-Z");
#ifdef _WIN32 #ifdef _WIN32
snprintf(control_id, ARGV_NUMBER_LEN, "%d", GetCurrentProcessId()); snprintf(control_id, ARGV_NUMBER_LEN, "%ld", GetCurrentProcessId());
argv = sync_pipe_add_arg(argv, &argc, control_id); argv = sync_pipe_add_arg(argv, &argc, control_id);
#else #else
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE); argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
@ -2100,7 +2100,7 @@ static void create_dummy_signal_pipe() {
if (dummy_signal_pipe != NULL) return; if (dummy_signal_pipe != NULL) return;
if (!dummy_control_id) { if (!dummy_control_id) {
dummy_control_id = ws_strdup_printf("%d.dummy", GetCurrentProcessId()); dummy_control_id = ws_strdup_printf("%ld.dummy", GetCurrentProcessId());
} }
/* Create the signal pipe */ /* Create the signal pipe */

View File

@ -194,7 +194,7 @@ capture_opts_log(const char *log_domain, enum ws_log_level log_level, capture_op
ws_log(log_domain, log_level, "Promiscuous Mode[%02d]: %s", i, interface_opts->promisc_mode?"TRUE":"FALSE"); ws_log(log_domain, log_level, "Promiscuous Mode[%02d]: %s", i, interface_opts->promisc_mode?"TRUE":"FALSE");
ws_log(log_domain, log_level, "Extcap[%02d] : %s", i, interface_opts->extcap ? interface_opts->extcap : "(unspecified)"); ws_log(log_domain, log_level, "Extcap[%02d] : %s", i, interface_opts->extcap ? interface_opts->extcap : "(unspecified)");
ws_log(log_domain, log_level, "Extcap FIFO[%02d] : %s", i, interface_opts->extcap_fifo ? interface_opts->extcap_fifo : "(unspecified)"); ws_log(log_domain, log_level, "Extcap FIFO[%02d] : %s", i, interface_opts->extcap_fifo ? interface_opts->extcap_fifo : "(unspecified)");
ws_log(log_domain, log_level, "Extcap PID[%02d] : %d", i, interface_opts->extcap_pid); ws_log(log_domain, log_level, "Extcap PID[%02d] : %"PRIdMAX, i, (intmax_t)interface_opts->extcap_pid);
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
ws_log(log_domain, log_level, "Buffer size[%02d] : %d (MB)", i, interface_opts->buffer_size); ws_log(log_domain, log_level, "Buffer size[%02d] : %d (MB)", i, interface_opts->buffer_size);
#endif #endif

View File

@ -506,13 +506,13 @@ abs_time_to_rfc3339(wmem_allocator_t *scope, const nstime_t *nstime, bool use_ut
if (use_utc) { if (use_utc) {
tm = gmtime(&nstime->secs); tm = gmtime(&nstime->secs);
if (tm != NULL) if (tm != NULL)
strftime(datetime_format, sizeof(datetime_format), "%FT%T%%sZ", tm); strftime(datetime_format, sizeof(datetime_format), "%Y-%m-%dT%H:%M:%S%%sZ", tm);
else else
snprintf(datetime_format, sizeof(datetime_format), "Not representable"); snprintf(datetime_format, sizeof(datetime_format), "Not representable");
} else { } else {
tm = localtime(&nstime->secs); tm = localtime(&nstime->secs);
if (tm != NULL) if (tm != NULL)
strftime(datetime_format, sizeof(datetime_format), "%FT%T%%s%z", tm); strftime(datetime_format, sizeof(datetime_format), "%Y-%m-%dT%H:%M:%S%%s%z", tm);
else else
snprintf(datetime_format, sizeof(datetime_format), "Not representable"); snprintf(datetime_format, sizeof(datetime_format), "Not representable");
} }

View File

@ -417,7 +417,7 @@ static void snort_reaper(GPid pid, gint status _U_, gpointer data)
session->working = session->running = FALSE; session->working = session->running = FALSE;
/* XXX, cleanup */ /* XXX, cleanup */
} else { } else {
g_print("Errrrmm snort_reaper() %d != %d\n", session->pid, pid); g_print("Errrrmm snort_reaper() %"PRIdMAX" != %"PRIdMAX"\n", (intmax_t)session->pid, (intmax_t)pid);
} }
/* Close the snort pid (may only make a difference on Windows?) */ /* Close the snort pid (may only make a difference on Windows?) */

View File

@ -1255,8 +1255,8 @@ void extcap_request_stop(capture_session *cap_session)
continue; continue;
} }
ws_debug("Extcap [%s] - Requesting stop PID: %d", interface_opts->name, ws_debug("Extcap [%s] - Requesting stop PID: %"PRIdMAX, interface_opts->name,
interface_opts->extcap_pid); (intmax_t)interface_opts->extcap_pid);
#ifndef _WIN32 #ifndef _WIN32
if (interface_opts->extcap_pid != WS_INVALID_PID) if (interface_opts->extcap_pid != WS_INVALID_PID)
@ -1499,8 +1499,8 @@ static void extcap_child_watch_cb(GPid pid, gint status _U_, gpointer user_data)
interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i); interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
if (interface_opts->extcap_pid == pid) if (interface_opts->extcap_pid == pid)
{ {
ws_debug("Extcap [%s] - Closing spawned PID: %d", interface_opts->name, ws_debug("Extcap [%s] - Closing spawned PID: %"PRIdMAX, interface_opts->name,
interface_opts->extcap_pid); (intmax_t)interface_opts->extcap_pid);
interface_opts->extcap_pid = WS_INVALID_PID; interface_opts->extcap_pid = WS_INVALID_PID;
extcap_watch_removed(cap_session, interface_opts); extcap_watch_removed(cap_session, interface_opts);
break; break;
@ -1648,13 +1648,13 @@ static gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, HANDLE *ha
if (*handle_out == INVALID_HANDLE_VALUE) if (*handle_out == INVALID_HANDLE_VALUE)
{ {
ws_debug("Error creating pipe => (%d)", GetLastError()); ws_debug("Error creating pipe => (%ld)", GetLastError());
g_free (pipename); g_free (pipename);
return FALSE; return FALSE;
} }
else else
{ {
ws_debug("Wireshark Created pipe =>(%s) handle (%" PRIuPTR ")", pipename, *handle_out); ws_debug("Wireshark Created pipe =>(%s) handle (%" PRIuMAX ")", pipename, (uintmax_t)*handle_out);
*fifo = g_strdup(pipename); *fifo = g_strdup(pipename);
} }

View File

@ -624,7 +624,7 @@ configuration_init_w32(const char* arg0 _U_)
/* /*
* Gak. We can't format the message. * Gak. We can't format the message.
*/ */
return ws_strdup_printf("GetModuleFileName failed: %u (FormatMessage failed: %u)", return ws_strdup_printf("GetModuleFileName failed: %lu (FormatMessage failed: %lu)",
error, GetLastError()); error, GetLastError());
} }
msg = utf_16to8(msg_w); msg = utf_16to8(msg_w);
@ -638,7 +638,7 @@ configuration_init_w32(const char* arg0 _U_)
msg[msglen - 1] = '\0'; msg[msglen - 1] = '\0';
msg[msglen - 2] = '\0'; msg[msglen - 2] = '\0';
} }
return ws_strdup_printf("GetModuleFileName failed: %s (%u)", return ws_strdup_printf("GetModuleFileName failed: %s (%lu)",
msg, error); msg, error);
} }

View File

@ -183,7 +183,7 @@ win32strexception(DWORD exception)
if (exceptions[i].code == exception) if (exceptions[i].code == exception)
return exceptions[i].msg; return exceptions[i].msg;
} }
snprintf(errbuf, (gulong)sizeof errbuf, "Exception 0x%08x", exception); snprintf(errbuf, (gulong)sizeof errbuf, "Exception 0x%08lx", exception);
return errbuf; return errbuf;
} }

View File

@ -125,7 +125,7 @@ ws_pipe_create_overlapped_read(HANDLE *read_pipe_handle, HANDLE *write_pipe_hand
SECURITY_ATTRIBUTES *sa, DWORD suggested_buffer_size) SECURITY_ATTRIBUTES *sa, DWORD suggested_buffer_size)
{ {
HANDLE read_pipe, write_pipe; HANDLE read_pipe, write_pipe;
guchar *name = ws_strdup_printf("\\\\.\\Pipe\\WiresharkWsPipe.%08x.%08x", guchar *name = ws_strdup_printf("\\\\.\\Pipe\\WiresharkWsPipe.%08lx.%08lx",
GetCurrentProcessId(), GetCurrentProcessId(),
InterlockedIncrement(&pipe_serial_number)); InterlockedIncrement(&pipe_serial_number));
gunichar2 *wname = g_utf8_to_utf16(name, -1, NULL, NULL, NULL); gunichar2 *wname = g_utf8_to_utf16(name, -1, NULL, NULL, NULL);
@ -336,7 +336,7 @@ gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command
{ {
if (GetLastError() != ERROR_IO_PENDING) if (GetLastError() != ERROR_IO_PENDING)
{ {
ws_debug("ReadFile on child stdout pipe failed. Error %d", GetLastError()); ws_debug("ReadFile on child stdout pipe failed. Error %ld", GetLastError());
pending_stdout = FALSE; pending_stdout = FALSE;
} }
} }
@ -345,7 +345,7 @@ gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command
{ {
if (GetLastError() != ERROR_IO_PENDING) if (GetLastError() != ERROR_IO_PENDING)
{ {
ws_debug("ReadFile on child stderr pipe failed. Error %d", GetLastError()); ws_debug("ReadFile on child stderr pipe failed. Error %ld", GetLastError());
pending_stderr = FALSE; pending_stderr = FALSE;
} }
} }
@ -396,7 +396,7 @@ gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command
pending_stdout = FALSE; pending_stdout = FALSE;
continue; continue;
} }
ws_debug("GetOverlappedResult on stdout failed. Error %d", GetLastError()); ws_debug("GetOverlappedResult on stdout failed. Error %ld", GetLastError());
} }
if (process_finished && (bytes_read == 0)) if (process_finished && (bytes_read == 0))
{ {
@ -409,7 +409,7 @@ gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command
{ {
if (GetLastError() != ERROR_IO_PENDING) if (GetLastError() != ERROR_IO_PENDING)
{ {
ws_debug("ReadFile on child stdout pipe failed. Error %d", GetLastError()); ws_debug("ReadFile on child stdout pipe failed. Error %ld", GetLastError());
pending_stdout = FALSE; pending_stdout = FALSE;
} }
} }
@ -425,7 +425,7 @@ gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command
pending_stderr = FALSE; pending_stderr = FALSE;
continue; continue;
} }
ws_debug("GetOverlappedResult on stderr failed. Error %d", GetLastError()); ws_debug("GetOverlappedResult on stderr failed. Error %ld", GetLastError());
} }
if (process_finished && (bytes_read == 0)) if (process_finished && (bytes_read == 0))
{ {
@ -436,7 +436,7 @@ gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command
{ {
if (GetLastError() != ERROR_IO_PENDING) if (GetLastError() != ERROR_IO_PENDING)
{ {
ws_debug("ReadFile on child stderr pipe failed. Error %d", GetLastError()); ws_debug("ReadFile on child stderr pipe failed. Error %ld", GetLastError());
pending_stderr = FALSE; pending_stderr = FALSE;
} }
} }
@ -444,7 +444,7 @@ gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command
} }
else else
{ {
ws_debug("WaitForMultipleObjects returned 0x%08X. Error %d", dw, GetLastError()); ws_debug("WaitForMultipleObjects returned 0x%08lX. Error %ld", dw, GetLastError());
} }
} }
@ -721,7 +721,7 @@ ws_pipe_wait_for_pipe(HANDLE * pipe_handles, int num_pipe_handles, HANDLE pid)
break; break;
default: default:
ws_debug("ConnectNamedPipe failed with %d\n.", error); ws_debug("ConnectNamedPipe failed with %ld\n.", error);
result = FALSE; result = FALSE;
} }
} }
@ -776,7 +776,7 @@ ws_pipe_wait_for_pipe(HANDLE * pipe_handles, int num_pipe_handles, HANDLE pid)
TRUE); // wait TRUE); // wait
if (!success) if (!success)
{ {
ws_debug("Error %d \n.", GetLastError()); ws_debug("Error %ld \n.", GetLastError());
result = FALSE; result = FALSE;
} }
pipeinsts[i].pendingIO = FALSE; pipeinsts[i].pendingIO = FALSE;
@ -785,7 +785,7 @@ ws_pipe_wait_for_pipe(HANDLE * pipe_handles, int num_pipe_handles, HANDLE pid)
} }
else else
{ {
ws_debug("WaitForMultipleObjects returned 0x%08X. Error %d", dw, GetLastError()); ws_debug("WaitForMultipleObjects returned 0x%08lX. Error %ld", dw, GetLastError());
result = FALSE; result = FALSE;
} }
} }