Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 May 2013 01:33:16 GMT
From:      Garrett Cooper <yaneurabeya@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/178764: [PATCH] [bluetooth] synch __arraycount definition fix a -Wsign-compare warning
Message-ID:  <201305190133.r4J1XGxe050324@oldred.FreeBSD.org>
Resent-Message-ID: <201305190140.r4J1e0Vw065642@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         178764
>Category:       bin
>Synopsis:       [PATCH] [bluetooth] synch __arraycount definition fix a -Wsign-compare warning
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 19 01:40:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Garrett Cooper
>Release:        10-CURRENT
>Organization:
EMC Isilon
>Environment:
FreeBSD fuji-current.local 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r250326: Thu May 16 13:51:42 PDT 2013     root@fuji-current.local:/usr/obj/usr/src.svn/sys/FUJI-NOCOMPAT  i386
>Description:
The attached patch updates the __arraycount definition to match upstream's (NetBSD's) definition and fixes the -Wsign-compare error.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

>From 9637e70133b6edfba4a37bde22909ee6e9d21ede Mon Sep 17 00:00:00 2001
From: Garrett Cooper <yanegomi@gmail.com>
Date: Sat, 18 May 2013 17:47:21 -0700
Subject: [PATCH] Synch __arraycount with upstream's definition

Subsequently, fix a -Wsign-compare error with clang due to
synching __arraycount's definition.

Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
---
 usr.sbin/bluetooth/btpand/btpand.c | 4 ++--
 usr.sbin/bluetooth/btpand/btpand.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/bluetooth/btpand/btpand.c b/usr.sbin/bluetooth/btpand/btpand.c
index 9387444..8895db2 100644
--- a/usr.sbin/bluetooth/btpand/btpand.c
+++ b/usr.sbin/bluetooth/btpand/btpand.c
@@ -146,7 +146,7 @@ main(int argc, char *argv[])
 		case 's': /* service */
 		case 'S': /* service (no SDP) */
 			for (ul = 0; strcasecmp(optarg, services[ul].name); ul++) {
-				if (ul == __arraycount(services))
+				if (ul == (unsigned long)__arraycount(services))
 					errx(EXIT_FAILURE, "%s: unknown service", optarg);
 			}
 
@@ -264,7 +264,7 @@ static void
 usage(void)
 {
 	const char *p = getprogname();
-	int n = strlen(p);
+	size_t n = strlen(p);
 
 	fprintf(stderr,
 	    "usage: %s [-i ifname] [-m mode] -a address -d device\n"
diff --git a/usr.sbin/bluetooth/btpand/btpand.h b/usr.sbin/bluetooth/btpand/btpand.h
index c5f7204..440cca1 100644
--- a/usr.sbin/bluetooth/btpand/btpand.h
+++ b/usr.sbin/bluetooth/btpand/btpand.h
@@ -44,7 +44,7 @@
 #include "event.h"
 
 #ifndef __arraycount
-#define __arraycount(__x)	(int)(sizeof((__x)) / sizeof((__x)[0]))
+#define __arraycount(__x)	(sizeof(__x) / sizeof(__x[0]))
 #endif
 
 #ifndef	L2CAP_PSM_INVALID
-- 
1.8.2.3



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305190133.r4J1XGxe050324>