Skip to content

Commit

Permalink
Fix a bunch of warnings.
Browse files Browse the repository at this point in the history
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
  • Loading branch information
guyharris committed Dec 26, 2012
1 parent 8ede6b7 commit 8ed7a73
Show file tree
Hide file tree
Showing 289 changed files with 2,352 additions and 2,464 deletions.
2 changes: 0 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -861,11 +861,9 @@ EXTRA_DIST = \
$(tpncp_DATA) \
$(ui_DATA) \
$(wimaxasncp_DATA) \
randpkt.c \
reordercap.c \
smi_modules \
text2pcap-scanner.l \
text2pcap.c \
text2pcap.h \
services \
wireshark.desktop \
Expand Down
10 changes: 5 additions & 5 deletions airpcap_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ write_wlan_wep_keys_to_registry(airpcap_if_info_t* info_if, GList* key_list)
/*
* Calculate the size of the keys collection
*/
KeysCollectionSize = sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey);
KeysCollectionSize = (guint)(sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey));

/*
* Allocate the collection
Expand Down Expand Up @@ -449,7 +449,7 @@ write_wlan_driver_wep_keys_to_registry(GList* key_list)
/*
* Calculate the size of the keys collection
*/
KeysCollectionSize = sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey);
KeysCollectionSize = (guint)(sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey));

/*
* Allocate the collection
Expand Down Expand Up @@ -568,7 +568,7 @@ save_wlan_driver_wep_keys(void)

/* Number of keys in key list */
if (fake_info_if->keysCollectionSize != 0)
keys_in_list = (guint)(fake_info_if->keysCollectionSize - sizeof(AirpcapKeysCollection))/sizeof(AirpcapKey);
keys_in_list = (guint)((fake_info_if->keysCollectionSize - sizeof(AirpcapKeysCollection))/sizeof(AirpcapKey));
else
keys_in_list = 0;

Expand Down Expand Up @@ -1775,7 +1775,7 @@ get_airpcap_device_keys(airpcap_if_info_t* info_if)

/* Number of keys in key list */
if (info_if->keysCollectionSize != 0)
keys_in_list = (guint)(info_if->keysCollectionSize - sizeof(AirpcapKeysCollection))/sizeof(AirpcapKey);
keys_in_list = (guint)((info_if->keysCollectionSize - sizeof(AirpcapKeysCollection))/sizeof(AirpcapKey));
else
keys_in_list = 0;

Expand Down Expand Up @@ -1847,7 +1847,7 @@ get_airpcap_driver_keys(void)

/* Number of keys in key list */
if (fake_info_if->keysCollectionSize != 0)
keys_in_list = (guint)(fake_info_if->keysCollectionSize - sizeof(AirpcapKeysCollection))/sizeof(AirpcapKey);
keys_in_list = (guint)((fake_info_if->keysCollectionSize - sizeof(AirpcapKeysCollection))/sizeof(AirpcapKey));
else
keys_in_list = 0;

Expand Down
2 changes: 1 addition & 1 deletion asn1/ansi_map/packet-ansi_map-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ update_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb
address* dst = &(pinfo->dst);
guint8 *src_str;
guint8 *dst_str;
char *buf = NULL;
const char *buf = NULL;

src_str = ep_address_to_str(src);
dst_str = ep_address_to_str(dst);
Expand Down
2 changes: 1 addition & 1 deletion asn1/disp/packet-disp-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ dissect_disp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
proto_item *item=NULL;
proto_tree *tree=NULL;
int (*disp_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) = NULL;
char *disp_op_name;
const char *disp_op_name;
asn1_ctx_t asn1_ctx;

asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
Expand Down
6 changes: 3 additions & 3 deletions asn1/dop/packet-dop-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int proto_dop = -1;
static struct SESSION_DATA_STRUCTURE* session = NULL;
static const char *binding_type = NULL; /* binding_type */

static int call_dop_oid_callback(char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *col_info);
static int call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, const char *col_info);

#include "packet-dop-hf.c"

Expand All @@ -83,7 +83,7 @@ static void append_oid(packet_info *pinfo, const char *oid)
#include "packet-dop-fn.c"

static int
call_dop_oid_callback(char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *col_info)
call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, const char *col_info)
{
char* binding_param;

Expand Down Expand Up @@ -120,7 +120,7 @@ dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
proto_item *item=NULL;
proto_tree *tree=NULL;
int (*dop_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) = NULL;
char *dop_op_name;
const char *dop_op_name;
asn1_ctx_t asn1_ctx;

asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
Expand Down
2 changes: 1 addition & 1 deletion asn1/dsp/packet-dsp-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
proto_item *item=NULL;
proto_tree *tree=NULL;
int (*dsp_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) = NULL;
char *dsp_op_name;
const char *dsp_op_name;
asn1_ctx_t asn1_ctx;

asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
Expand Down
2 changes: 1 addition & 1 deletion asn1/mms/mms.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE
/* 86400 seconds in one day */

ts.secs = (days + 5113) * 86400 + milliseconds / 1000;
ts.nsecs = (milliseconds %% 1000) * G_GINT64_CONSTANT(1000000U);
ts.nsecs = (milliseconds %% 1000) * 1000000U;

ptime = abs_time_to_str(&ts, ABSOLUTE_TIME_UTC, TRUE);
if(hf_index >= 0)
Expand Down
2 changes: 1 addition & 1 deletion asn1/p1/packet-p1-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
proto_item *item=NULL;
proto_tree *tree=NULL;
int (*p1_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) = NULL;
char *p1_op_name;
const char *p1_op_name;
int hf_p1_index = -1;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
Expand Down
2 changes: 2 additions & 0 deletions asn1/pkix1explicit/packet-pkix1explicit-template.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

int dissect_pkix1explicit_Certificate(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
int dissect_pkix1explicit_CertificateList(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
#if 0
int dissect_pkix1explicit_CertificateSerialNumber(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
#endif
int dissect_pkix1explicit_Name(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
int dissect_pkix1explicit_GeneralName(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
int dissect_pkix1explicit_AlgorithmIdentifier(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx,proto_tree *tree, int hf_index);
Expand Down
4 changes: 2 additions & 2 deletions asn1/rtse/rtse.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RTORJapdu
RTABapdu

#.FN_BODY RTORJapdu/userDataRJ
char *oid = NULL;
const char *oid = NULL;

switch(app_proto) {
case 1: /* mts-transfer-protocol-1984 */
Expand Down Expand Up @@ -51,7 +51,7 @@ RTABapdu
#.FN_BODY ConnectionData/open
char *oid = NULL;
const char *oid = NULL;
switch(app_proto) {
case 1: /* mts-transfer-protocol-1984 */
Expand Down
10 changes: 5 additions & 5 deletions asn1/spnego/packet-spnego-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,11 @@ arcfour_mic_cksum(guint8 *key_data, int key_length,
*/
static int
gssapi_verify_pad(unsigned char *wrapped_data, int wrapped_length,
size_t datalen,
size_t *padlen)
int datalen,
int *padlen)
{
unsigned char *pad;
size_t padlength;
int padlength;
int i;

pad = wrapped_data + wrapped_length - 1;
Expand All @@ -449,14 +449,14 @@ decrypt_arcfour(packet_info *pinfo,
{
guint8 Klocaldata[16];
int ret;
size_t datalen;
int datalen;
guint8 k6_data[16];
guint32 SND_SEQ[2];
guint8 Confounder[8];
guint8 cksum_data[8];
int cmp;
int conf_flag;
size_t padlen = 0;
int padlen = 0;

datalen = tvb_length(pinfo->gssapi_encrypted_tvb);

Expand Down
2 changes: 1 addition & 1 deletion capture_opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
}
return 2;
}
if_info = (if_info_t *)g_list_nth_data(if_list, adapter_index - 1);
if_info = (if_info_t *)g_list_nth_data(if_list, (int)(adapter_index - 1));
if (if_info == NULL) {
cmdarg_err("There is no interface with that adapter index");
return 1;
Expand Down
45 changes: 23 additions & 22 deletions capture_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static const char *sync_pipe_signame(int);
static gboolean sync_pipe_input_cb(gint source, gpointer user_data);
static int sync_pipe_wait_for_child(int fork_child, gchar **msgp);
static void pipe_convert_header(const guchar *header, int header_len, char *indicator, int *block_len);
static int pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
static ssize_t pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
char **err_msg);


Expand Down Expand Up @@ -949,15 +949,15 @@ sync_pipe_run_command(const char** argv, gchar **data, gchar **primary_msg,
int data_pipe_read_fd, sync_pipe_read_fd, fork_child, ret;
char *wait_msg;
gchar buffer[PIPE_BUF_SIZE+1];
int nread;
ssize_t nread;
char indicator;
int primary_msg_len;
char *primary_msg_text;
int secondary_msg_len;
char *secondary_msg_text;
char *combined_msg;
GString *data_buf = NULL;
int count;
size_t count;

ret = sync_pipe_open_command(argv, &data_pipe_read_fd, &sync_pipe_read_fd,
&fork_child, &msg);
Expand Down Expand Up @@ -1262,7 +1262,7 @@ sync_interface_stats_open(int *data_read_fd, int *fork_child, gchar **msg)
int message_read_fd, ret;
char *wait_msg;
gchar buffer[PIPE_BUF_SIZE+1];
int nread;
ssize_t nread;
char indicator;
int primary_msg_len;
char *primary_msg_text;
Expand Down Expand Up @@ -1416,11 +1416,11 @@ sync_interface_stats_close(int *read_fd, int *fork_child, gchar **msg)

/* read a number of bytes from a pipe */
/* (blocks until enough bytes read or an error occurs) */
static int
static ssize_t
pipe_read_bytes(int pipe_fd, char *bytes, int required, char **msg)
{
int newly;
int offset = 0;
ssize_t newly;
ssize_t offset = 0;
int error;

while(required) {
Expand All @@ -1443,7 +1443,7 @@ pipe_read_bytes(int pipe_fd, char *bytes, int required, char **msg)
return newly;
}

required -= newly;
required -= (int)newly;
offset += newly;
}

Expand Down Expand Up @@ -1484,7 +1484,7 @@ static gboolean pipe_data_available(int pipe_fd) {
/* Read a line from a pipe, similar to fgets */
int
sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max) {
int newly;
ssize_t newly;
int offset = -1;

while(offset < max - 1) {
Expand All @@ -1495,11 +1495,11 @@ sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max) {
if (newly == 0) {
/* EOF - not necessarily an error */
break;
} else if (newly < 0) {
} else if (newly == -1) {
/* error */
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
"read from pipe %d: error(%u): %s", pipe_fd, errno, g_strerror(errno));
return newly;
return -1;
} else if (bytes[offset] == '\n') {
break;
}
Expand All @@ -1526,12 +1526,12 @@ pipe_convert_header(const guchar *header, int header_len, char *indicator, int *
/* read a message from the sending pipe in the standard format
(1-byte message indicator, 3-byte message length (excluding length
and indicator field), and the rest is the message) */
static int
static ssize_t
pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
char **err_msg)
{
int required;
int newly;
ssize_t newly;
guchar header[4];

/* read header (indicator and 3-byte length) */
Expand All @@ -1548,13 +1548,13 @@ pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
return 0;
}
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
"read %d failed to read header: %u", pipe_fd, newly);
"read %d failed to read header: %lu", pipe_fd, (long)newly);
if (newly != -1) {
/*
* Short read, but not an immediate EOF.
*/
*err_msg = g_strdup_printf("Premature EOF reading from sync pipe: got only %d bytes",
newly);
*err_msg = g_strdup_printf("Premature EOF reading from sync pipe: got only %ld bytes",
(long)newly);
}
return -1;
}
Expand Down Expand Up @@ -1617,13 +1617,14 @@ sync_pipe_input_cb(gint source, gpointer user_data)
capture_options *capture_opts = (capture_options *)user_data;
int ret;
char buffer[SP_MAX_MSG_LEN+1];
int nread;
ssize_t nread;
char indicator;
int primary_len;
char *primary_msg;
int secondary_len;
char *secondary_msg;
char *wait_msg, *combined_msg;
int npackets;

nread = pipe_read_block(source, &indicator, SP_MAX_MSG_LEN, buffer,
&primary_msg);
Expand Down Expand Up @@ -1701,9 +1702,9 @@ sync_pipe_input_cb(gint source, gpointer user_data)
}
break;
case SP_PACKET_COUNT:
nread = atoi(buffer);
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: new packets %u", nread);
capture_input_new_packets(capture_opts, nread);
npackets = atoi(buffer);
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: new packets %u", npackets);
capture_input_new_packets(capture_opts, npackets);
break;
case SP_ERROR_MSG:
/* convert primary message */
Expand Down Expand Up @@ -1817,8 +1818,8 @@ sync_pipe_wait_for_child(int fork_child, gchar **msgp)
#endif

g_get_current_time(&end_time);
elapsed = (end_time.tv_sec - start_time.tv_sec) +
((end_time.tv_usec - start_time.tv_usec) / (float) 1e6);
elapsed = (float) ((end_time.tv_sec - start_time.tv_sec) +
((end_time.tv_usec - start_time.tv_usec) / 1e6));
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_wait_for_child: capture child closed after %.3fs", elapsed);
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions clopts_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ get_natural_int(const char *string, const char *name)
name, string, INT_MAX);
exit(1);
}
return number;
return (int)number;
}


int
get_positive_int(const char *string, const char *name)
{
long number;
int number;

number = get_natural_int(string, name);

Expand Down
Loading

0 comments on commit 8ed7a73

Please sign in to comment.