From 97b1491ba3c93fa7d44b22f72e2be1eae6c96496 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 29 Jan 2009 17:23:53 +0100 Subject: Fix signed/unsigned integer comparison --- lib/hci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/hci.c b/lib/hci.c index 7e5ef940..c69cf399 100644 --- a/lib/hci.c +++ b/lib/hci.c @@ -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; } -- cgit