mka: Make csindex unsigned

This avoids unnecessary typecasting while still being able to compare
the value to CS_TABLE_SIZE without compiler warnings.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2016-08-22 21:02:40 +03:00
parent 343eb3b036
commit 535a8b8712
2 changed files with 7 additions and 6 deletions

View File

@ -1395,7 +1395,7 @@ ieee802_1x_mka_get_dist_sak_length(
struct ieee802_1x_mka_participant *participant) struct ieee802_1x_mka_participant *participant)
{ {
int length = MKA_HDR_LEN; int length = MKA_HDR_LEN;
int cs_index = participant->kay->macsec_csindex; unsigned int cs_index = participant->kay->macsec_csindex;
if (participant->advised_desired) { if (participant->advised_desired) {
length = sizeof(struct ieee802_1x_mka_dist_sak_body); length = sizeof(struct ieee802_1x_mka_dist_sak_body);
@ -1420,7 +1420,7 @@ ieee802_1x_mka_encode_dist_sak_body(
struct ieee802_1x_mka_dist_sak_body *body; struct ieee802_1x_mka_dist_sak_body *body;
struct data_key *sak; struct data_key *sak;
unsigned int length; unsigned int length;
int cs_index; unsigned int cs_index;
int sak_pos; int sak_pos;
length = ieee802_1x_mka_get_dist_sak_length(participant); length = ieee802_1x_mka_get_dist_sak_length(participant);
@ -3488,14 +3488,15 @@ ieee802_1x_kay_new_sak(struct ieee802_1x_kay *kay)
* ieee802_1x_kay_change_cipher_suite - * ieee802_1x_kay_change_cipher_suite -
*/ */
int int
ieee802_1x_kay_change_cipher_suite(struct ieee802_1x_kay *kay, int cs_index) ieee802_1x_kay_change_cipher_suite(struct ieee802_1x_kay *kay,
unsigned int cs_index)
{ {
struct ieee802_1x_mka_participant *participant; struct ieee802_1x_mka_participant *participant;
if (!kay) if (!kay)
return -1; return -1;
if ((unsigned int) cs_index >= CS_TABLE_SIZE) { if (cs_index >= CS_TABLE_SIZE) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"KaY: Configured cipher suite index is out of range"); "KaY: Configured cipher suite index is out of range");
return -1; return -1;

View File

@ -124,7 +124,7 @@ struct ieee802_1x_kay {
Boolean is_obliged_key_server; Boolean is_obliged_key_server;
char if_name[IFNAMSIZ]; char if_name[IFNAMSIZ];
int macsec_csindex; /* MACsec cipher suite table index */ unsigned int macsec_csindex; /* MACsec cipher suite table index */
int mka_algindex; /* MKA alg table index */ int mka_algindex; /* MKA alg table index */
u32 dist_kn; u32 dist_kn;
@ -169,7 +169,7 @@ void ieee802_1x_kay_mka_participate(struct ieee802_1x_kay *kay,
Boolean status); Boolean status);
int ieee802_1x_kay_new_sak(struct ieee802_1x_kay *kay); int ieee802_1x_kay_new_sak(struct ieee802_1x_kay *kay);
int ieee802_1x_kay_change_cipher_suite(struct ieee802_1x_kay *kay, int ieee802_1x_kay_change_cipher_suite(struct ieee802_1x_kay *kay,
int cs_index); unsigned int cs_index);
int ieee802_1x_kay_set_latest_sa_attr(struct ieee802_1x_kay *kay, int ieee802_1x_kay_set_latest_sa_attr(struct ieee802_1x_kay *kay,
struct ieee802_1x_mka_ki *lki, u8 lan, struct ieee802_1x_mka_ki *lki, u8 lan,