mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-02 01:28:02 +02:00
core: fix warning about comparing unsigned enum values being positive
clang warns:
make[4]: Entering directory `./NetworkManager/src'
CC nm-device.lo
devices/nm-device.c:367:12: error: comparison of unsigned enum expression >= 0 is always true [-Werror,-Wtautological-compare]
if (state >= 0 && state < G_N_ELEMENTS (state_table))
~~~~~ ^ ~
devices/nm-device.c:443:13: error: comparison of unsigned enum expression >= 0 is always true [-Werror,-Wtautological-compare]
if (reason >= 0 && reason < G_N_ELEMENTS (reason_table))
~~~~~~ ^ ~
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
0238f8f8e2
commit
a2a36d8450
4 changed files with 5 additions and 5 deletions
|
|
@ -364,7 +364,7 @@ static const char *state_table[] = {
|
|||
static const char *
|
||||
queued_state_to_string (NMDeviceState state)
|
||||
{
|
||||
if (state >= 0 && state < G_N_ELEMENTS (state_table))
|
||||
if ((gsize) state < G_N_ELEMENTS (state_table))
|
||||
return state_table[state];
|
||||
return state_table[NM_DEVICE_STATE_UNKNOWN];
|
||||
}
|
||||
|
|
@ -440,7 +440,7 @@ static const char *reason_table[] = {
|
|||
static const char *
|
||||
reason_to_string (NMDeviceStateReason reason)
|
||||
{
|
||||
if (reason >= 0 && reason < G_N_ELEMENTS (reason_table))
|
||||
if ((gsize) reason < G_N_ELEMENTS (reason_table))
|
||||
return reason_table[reason];
|
||||
return reason_table[NM_DEVICE_STATE_REASON_UNKNOWN];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ static const char *state_table[] = {
|
|||
const char *
|
||||
nm_modem_state_to_string (NMModemState state)
|
||||
{
|
||||
if (state >= 0 && state < G_N_ELEMENTS (state_table))
|
||||
if ((gsize) state < G_N_ELEMENTS (state_table))
|
||||
return state_table[state];
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ static const char *state_table[NM_DHCP_STATE_MAX + 1] = {
|
|||
static const char *
|
||||
state_to_string (NMDhcpState state)
|
||||
{
|
||||
if (state >= 0 && state < G_N_ELEMENTS (state_table))
|
||||
if ((gsize) state < G_N_ELEMENTS (state_table))
|
||||
return state_table[state];
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -665,7 +665,7 @@ static const char *state_table[] = {
|
|||
static const char *
|
||||
vpn_state_to_string (VpnState state)
|
||||
{
|
||||
if (state >= 0 && state < G_N_ELEMENTS (state_table))
|
||||
if ((gsize) state < G_N_ELEMENTS (state_table))
|
||||
return state_table[state];
|
||||
return "unknown";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue