MSVC: Warn about unused formal parameters

Provide _U_ macro definition for Visual Studio.

Change the way _U_ macro is ifdefed for some targets to allow Visual
Studio to recognize it.

Ping-Bug: 15832
Change-Id: Ic7ce145cbe9e8aa751d64c9c09ce8ba6c1bbbd30
Reviewed-on: https://code.wireshark.org/review/34530
Tested-by: Petri Dish Buildbot
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
laforge/q933
Tomasz Moń 3 years ago committed by Peter Wu
parent 29be7f9d9a
commit 893a2d9c62
  1. 3
      CMakeLists.txt
  2. 15
      caputils/capture-pcap-util.c
  3. 5
      dumpcap.c
  4. 2
      ui/win32/file_dlg_win32.c
  5. 2
      ws_attributes.h
  6. 3
      wsutil/file_util.c
  7. 6
      wsutil/filesystem.c
  8. 9
      wsutil/getopt_long.c

@ -427,10 +427,11 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
# Additional compiler warnings to be treated as "Level 3"
# when compiling Wireshark sources. (Selected from "level 4" warnings).
## 4295: array is too small to include a terminating null character
## 4100: unreferenced formal parameter
## 4189: local variable is initialized but not referenced
# Disable warnings about about use of flexible array members:
## 4200: nonstandard extension used : zero-sized array in struct/union
list(APPEND LOCAL_CFLAGS /w34295 /w34189 /wd4200)
list(APPEND LOCAL_CFLAGS /w34295 /w34100 /w34189 /wd4200)
# We've matched these to specific compiler versions using the
# checks above. There's no need to pass them to check_c_compiler_flag

@ -823,12 +823,13 @@ linktype_name_to_val(const char *linktype)
* rest-of-the-universe libpcap.
*/
int
get_pcap_datalink(pcap_t *pch, const char *devicename
#ifndef _AIX
_U_)
get_pcap_datalink(pcap_t *pch,
#ifdef _AIX
const char* devicename
#else
)
const char* devicename _U_
#endif
)
{
int datalink;
#ifdef _AIX
@ -1257,11 +1258,11 @@ get_if_capabilities_pcap_create(interface_options *interface_opts,
}
pcap_t *
open_capture_device_pcap_create(capture_options *capture_opts
open_capture_device_pcap_create(
#if defined(HAVE_PCAP_SET_TSTAMP_PRECISION) || defined (HAVE_PCAP_SET_TSTAMP_TYPE)
,
capture_options* capture_opts,
#else
_U_,
capture_options* capture_opts _U_,
#endif
interface_options *interface_opts, int timeout,
cap_device_open_err *open_err,

@ -591,9 +591,10 @@ relinquish_all_capabilities(void)
static const char *
get_pcap_failure_secondary_error_message(cap_device_open_err open_err,
#ifdef __hpux
const char *open_err_str
#ifndef __hpux
_U_
#else
const char* open_err_str _U_
#endif
)
{

@ -1477,7 +1477,7 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
}
static UINT_PTR CALLBACK
save_as_statstree_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
save_as_statstree_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param _U_, LPARAM l_param _U_) {
switch(msg) {
case WM_INITDIALOG:

@ -27,6 +27,8 @@ extern "C" {
#if defined(__GNUC__)
/* This includes clang */
#define _U_ __attribute__((unused))
#elif defined(_MSC_VER)
#define _U_ __pragma(warning(suppress:4100))
#else
#define _U_
#endif

@ -57,6 +57,7 @@
#include <stdlib.h>
#include "file_util.h"
#include "ws_attributes.h"
static gchar *program_path = NULL;
static gchar *system_path = NULL;
@ -189,7 +190,7 @@ ws_stdio_rename (const gchar *oldfilename, const gchar *newfilename)
* Since: 2.6
*/
int
ws_stdio_mkdir (const gchar *filename, int mode)
ws_stdio_mkdir (const gchar *filename, int mode _U_)
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;

@ -469,9 +469,11 @@ get_executable_path(void)
* g_mallocated string containing an error on failure.
*/
char *
init_progfile_dir(const char *arg0
init_progfile_dir(
#ifdef _WIN32
_U_
const char* arg0 _U_
#else
const char* arg0
#endif
)
{

@ -19,6 +19,7 @@
#endif
#include "config.h"
#include "ws_attributes.h"
#include <stdio.h>
@ -271,7 +272,13 @@ exchange (char **argv, struct _getopt_data *d)
/* Initialize the internal data when the first call is made. */
static const char *
_getopt_initialize (int argc, char *const *argv, const char *optstring,
_getopt_initialize (
#if defined _LIBC && defined USE_NONOPTION_FLAGS
int argc, char *const *argv,
#else
int argc _U_, char *const *argv _U_,
#endif
const char *optstring,
struct _getopt_data *d, int posixly_correct)
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0

Loading…
Cancel
Save