diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-01-29 17:23:53 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-01-29 17:23:53 +0100 |
commit | 97b1491ba3c93fa7d44b22f72e2be1eae6c96496 (patch) | |
tree | 41b68082f4927b998d69934a8b4e666a04678736 | |
parent | a563c8ed5a5d5004f4270dd8836f4257c1da2fe8 (diff) |
Fix signed/unsigned integer comparison
-rw-r--r-- | lib/hci.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -510,6 +510,7 @@ char *hci_cmdtostr(unsigned int cmd) char *hci_commandstostr(uint8_t *commands, char *pref, int width) { + unsigned int maxwidth = width - 3; hci_map *m; char *off, *ptr, *str; int size = 10; @@ -537,7 +538,7 @@ char *hci_commandstostr(uint8_t *commands, char *pref, int width) while (m->str) { if (commands[m->val / 8] & (1 << (m->val % 8))) { - if (strlen(off) + strlen(m->str) > width - 3) { + if (strlen(off) + strlen(m->str) > maxwidth) { ptr += sprintf(ptr, "\n%s", pref ? pref : ""); off = ptr; } @@ -670,6 +671,7 @@ static hci_map lmp_features_map[8][9] = { char *lmp_featurestostr(uint8_t *features, char *pref, int width) { + unsigned int maxwidth = width - 1; char *off, *ptr, *str; int i, size = 10; @@ -699,7 +701,7 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width) while (m->str) { if (m->val & features[i]) { - if (strlen(off) + strlen(m->str) > width - 1) { + if (strlen(off) + strlen(m->str) > maxwidth) { ptr += sprintf(ptr, "\n%s", pref ? pref : ""); off = ptr; } |