Skip to content

Commit

Permalink
Add asserts to tell static analyzer we know what we're doing...
Browse files Browse the repository at this point in the history
nfc.c:1244:19: warning: Dereference of undefined pointer value
  for (int i = 0; nmt[i]; i++) {
                  ^~~~~~
nfc.c:1256:23: warning: Dereference of undefined pointer value
      for (int j = 0; nbr[j]; j++) {
                      ^~~~~~
  • Loading branch information
doegox committed Feb 18, 2017
1 parent f2c264d commit 2033519
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libnfc/nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <assert.h>

#include <nfc/nfc.h>

Expand Down Expand Up @@ -1237,13 +1238,14 @@ static int
nfc_device_validate_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation *nm)
{
int res;
const nfc_modulation_type *nmt;
const nfc_modulation_type *nmt = NULL;
if ((res = nfc_device_get_supported_modulation(pnd, mode, &nmt)) < 0) {
return res;
}
assert(nmt != NULL);
for (int i = 0; nmt[i]; i++) {
if (nmt[i] == nm->nmt) {
const nfc_baud_rate *nbr;
const nfc_baud_rate *nbr = NULL;
if (mode == N_INITIATOR) {
if ((res = nfc_device_get_supported_baud_rate(pnd, nmt[i], &nbr)) < 0) {
return res;
Expand All @@ -1253,6 +1255,7 @@ nfc_device_validate_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_m
return res;
}
}
assert(nbr != NULL);
for (int j = 0; nbr[j]; j++) {
if (nbr[j] == nm->nbr)
return NFC_SUCCESS;
Expand Down

0 comments on commit 2033519

Please sign in to comment.