diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-05-18 00:41:30 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-05-18 00:41:30 +0000 |
commit | 055ff08c2fb07e195e9fa69ba461ad1edad58779 (patch) | |
tree | 28408ddf5385f7cd87f179cb43c32764dd4d440b /wiretap/wtap.c | |
parent | 288e81e40ffabb34ccca5990f83a2e9bca4cb9cf (diff) | |
download | wireshark-055ff08c2fb07e195e9fa69ba461ad1edad58779.tar.gz |
Use g_array_index() to get at elements of the encapsulation table array;
this avoids some compiler warnings from clang about alignment.
svn path=/trunk/; revision=49398
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r-- | wiretap/wtap.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 198e6f77ce..35b33c6045 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -613,7 +613,9 @@ static struct encap_type_info encap_table_base[] = { WS_DLL_LOCAL gint wtap_num_encap_types = sizeof(encap_table_base) / sizeof(struct encap_type_info); static GArray* encap_table_arr = NULL; -static const struct encap_type_info* encap_table = NULL; + +#define encap_table_entry(encap) \ + g_array_index(encap_table_arr, struct encap_type_info, encap) static void wtap_init_encap_types(void) { @@ -622,8 +624,6 @@ static void wtap_init_encap_types(void) { encap_table_arr = g_array_new(FALSE,TRUE,sizeof(struct encap_type_info)); g_array_append_vals(encap_table_arr,encap_table_base,wtap_num_encap_types); - - encap_table = (struct encap_type_info *)encap_table_arr->data; } int wtap_get_num_encap_types(void) { @@ -641,8 +641,6 @@ int wtap_register_encap_type(const char* name, const char* short_name) { g_array_append_val(encap_table_arr,e); - encap_table = (struct encap_type_info *)encap_table_arr->data; - return wtap_num_encap_types++; } @@ -656,7 +654,7 @@ wtap_encap_string(int encap) else if (encap == WTAP_ENCAP_PER_PACKET) return "Per packet"; else - return encap_table[encap].name; + return encap_table_entry(encap).name; } /* Name to use in, say, a command-line flag specifying the type. */ @@ -668,7 +666,7 @@ wtap_encap_short_string(int encap) else if (encap == WTAP_ENCAP_PER_PACKET) return "per-packet"; else - return encap_table[encap].short_name; + return encap_table_entry(encap).short_name; } /* Translate a short name to a capture file type. */ @@ -678,8 +676,8 @@ wtap_short_string_to_encap(const char *short_name) int encap; for (encap = 0; encap < WTAP_NUM_ENCAP_TYPES; encap++) { - if (encap_table[encap].short_name != NULL && - strcmp(short_name, encap_table[encap].short_name) == 0) + if (encap_table_entry(encap).short_name != NULL && + strcmp(short_name, encap_table_entry(encap).short_name) == 0) return encap; } return -1; /* no such encapsulation type */ |