Cleanup: replace sizeof(arr)/sizeof(arr[0]) with shorter array_length(arr)

svn path=/trunk/; revision=36986
This commit is contained in:
Jakub Zawadzki 2011-05-04 19:32:35 +00:00
parent 0f6d022e33
commit 38c2f2a151
9 changed files with 11 additions and 13 deletions

View File

@ -3733,7 +3733,7 @@ dcm_init(void)
/* Add UID objects to hash table */
if (dcm_uid_table == NULL) {
dcm_uid_table = g_hash_table_new(g_str_hash, g_str_equal);
for (i = 0; i < sizeof(dcm_uid_data) / sizeof(dcm_uid_t); i++) {
for (i = 0; i < array_length(dcm_uid_data); i++) {
g_hash_table_insert(dcm_uid_table, (gpointer) dcm_uid_data[i].value,
(gpointer) &dcm_uid_data[i]);
}
@ -3742,7 +3742,7 @@ dcm_init(void)
/* Add Tag objects to hash table */
if (dcm_tag_table == NULL) {
dcm_tag_table = g_hash_table_new(NULL, NULL);
for (i = 0; i < sizeof(dcm_tag_data) / sizeof(dcm_tag_t); i++) {
for (i = 0; i < array_length(dcm_tag_data); i++) {
g_hash_table_insert(dcm_tag_table, GUINT_TO_POINTER(dcm_tag_data[i].tag),
(gpointer) &dcm_tag_data[i]);
}
@ -3751,7 +3751,7 @@ dcm_init(void)
/* Add Status Values to hash table */
if (dcm_status_table == NULL) {
dcm_status_table = g_hash_table_new(NULL, NULL);
for (i = 0; i < sizeof(dcm_status_data) / sizeof(dcm_status_t); i++) {
for (i = 0; i < array_length(dcm_status_data); i++) {
g_hash_table_insert(dcm_status_table, GUINT_TO_POINTER((guint32)dcm_status_data[i].value),
(gpointer)&dcm_status_data[i]);
}

View File

@ -593,7 +593,7 @@ dns_type_description (guint type)
if (short_name == NULL) {
return ep_strdup_printf("Unknown (%u)", type);
}
if (type < sizeof(type_names)/sizeof(type_names[0]))
if (type < array_length(type_names))
long_name = type_names[type];
else {
/* special cases */

View File

@ -286,7 +286,7 @@ static const voip_call_state tap_cmd_voip_state[] = {
VOIP_UNKNOWN, /*TKOFFHK*/
VOIP_UNKNOWN /*OFFHOOK*/
};
#define NUM_TAP_CMD_VOIP_STATES (sizeof tap_cmd_voip_state / sizeof tap_cmd_voip_state[0])
#define NUM_TAP_CMD_VOIP_STATES array_length(tap_cmd_voip_state)
/* Subclassess for Modem packets */
static const value_string iax_modem_subclasses[] = {

View File

@ -1114,7 +1114,7 @@ static const ip_tcp_opt ipopts[] = {
}
};
#define N_IP_OPTS (sizeof ipopts / sizeof ipopts[0])
#define N_IP_OPTS array_length(ipopts)
/* Dissect the IP or TCP options in a packet. */
void

View File

@ -1452,9 +1452,7 @@ dissect_rtcp_app( tvbuff_t *tvb,packet_info *pinfo, int offset, proto_tree *tree
packet_len -= 4;
/* One SDES item for every set flag in contents array */
for ( i = 0;
i < sizeof(contents) / sizeof(contents[0]);
++i ) {
for ( i = 0; i < array_length(contents); ++i ) {
if ( contents[i] ) {
guint sdes_type2, sdes_len2;
/* (sdes_type2 not currently used...). Could complain if type

View File

@ -290,7 +290,7 @@ static const char *rtsp_methods[] = {
"TEARDOWN"
};
#define RTSP_NMETHODS (sizeof rtsp_methods / sizeof rtsp_methods[0])
#define RTSP_NMETHODS array_length(rtsp_methods)
static gboolean
is_rtsp_request_or_reply(const guchar *line, size_t linelen, rtsp_type_t *type)

View File

@ -4379,7 +4379,7 @@ static struct create_context_data_dissectors*
get_create_context_data_dissectors(const char *tag)
{
size_t i;
for (i=0; i<sizeof(create_context_dissectors_array)/sizeof(create_context_dissectors_array[0]); i++) {
for (i=0; i<array_length(create_context_dissectors_array); i++) {
if (!strcmp(tag, create_context_dissectors_array[i].tag))
return &create_context_dissectors_array[i].dissectors;
}

View File

@ -3377,7 +3377,7 @@ static const ip_tcp_opt tcpopts[] = {
}
};
#define N_TCP_OPTS (sizeof tcpopts / sizeof tcpopts[0])
#define N_TCP_OPTS array_length(tcpopts)
/* Determine if there is a sub-dissector and call it; return TRUE
if there was a sub-dissector, FALSE otherwise.

View File

@ -1516,7 +1516,7 @@ static tn_opt options[] = {
};
#define NOPTIONS (sizeof options / sizeof options[0])
#define NOPTIONS array_length(options)
static int
telnet_sub_option(packet_info *pinfo, proto_tree *telnet_tree, tvbuff_t *tvb, int start_offset)