From nobody Mon Apr 29 04:27:11 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VSVfS3wd1z5JBSC; Mon, 29 Apr 2024 04:27:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VSVfS0qX4z416f; Mon, 29 Apr 2024 04:27:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714364832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Bzlx66yR2n6ZOMyN59m/GthgMlbXbC4fUVP7M5t063I=; b=HPJ5wloyC68EKRuDO2LYLfJHa+dUQtwWVZjejDVFs6yGAOcwctd2eUeCDIMW6GHwNmbpkU RiWz5zr1aVV4TEZi91jW3QHveSxj1QLReWxy6eT2Bcy4DqbfMlqeQ9GbeSIUa+opFzAJJn IsnuckzggvKMgh9tajzVzm8dQ5UTvJf8NUSTAaHDA21akN3bPVQZngaHPchNyThCr9qSmm 9Jx4wsI4qDM/Q2JaRWa0wn9euLVCS9wZLLdQseYZlGdNCswMFa3fUMmQMRvert/ikS9qgl f264VkOErRg3QXV8nlyGvF0cGRlOvu7ermUSwTGSRDWSYhTLh6ZnjX+iv8SDvA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714364832; a=rsa-sha256; cv=none; b=ZFKo/d5aV+HfLRT43KjvEJOIdgN/5sgjD+2cOLb7vDMyFOCkMY+OIEoQkKtzZ3pw002vIQ TV4ORi7zKLlR2+69OHlUZTuXUurL3t6zmxMFsuN5e5YJwuPeNO9LNu1Tu/ldFxk5Nj9MrX ljN1dgV10h6TeHArDCTN5zBk0KgvKPi9VPcya3gij70WmELRH8VUMnjqRed4DRBcNScrxW +JVjGWrDMzgLjgH9iTQICi8oSy5WuDx8o5eQXhZEb+Z2ig1shEcHHyao91RSJg8KpSmB/e xWzmfeEnlw2jE1okW370VdEBv4dmSfCmp9TS71/9d91PbQqG7rJxpUh+puRTuA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714364832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Bzlx66yR2n6ZOMyN59m/GthgMlbXbC4fUVP7M5t063I=; b=bHIRAZl+3rZ3QqLM/lh2GTkeE1GntOWHAspFxv6A0qlkV9Eh8M9da2hkaL6lB1NCGNNBTR y+SsY0QXRpirhEZlS7LX6R/OKclnVYtnYq97Ay0D414orvKt4KwkHMe0Q/UJ1Ca96kanXW idVpz7SgJ4suSBkmsoKkzjzz0cUqq2L+YrI6LFjXdJR6efqDgfmNTgC3y/d+GLhmOFhLnx HLVbS0tMYiJLVqFN1W78rj7O9702Er70ONFf0932uFEDirc1/GGrBX+qT0TdyVWtDS9Wan RMmegqs9rKgVZkyQFwhjd17D2lNpUBUeX3mw1+Onl4QKtbpz6LyoAaxJhenFyQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VSVfS03ZMzvHT; Mon, 29 Apr 2024 04:27:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43T4RBpG044445; Mon, 29 Apr 2024 04:27:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43T4RBcE044442; Mon, 29 Apr 2024 04:27:11 GMT (envelope-from git) Date: Mon, 29 Apr 2024 04:27:11 GMT Message-Id: <202404290427.43T4RBcE044442@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: fdbf7cab91ae - main - bluetooth: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0]) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fdbf7cab91ae9ae7ca87bd47acb7400813bd7160 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=fdbf7cab91ae9ae7ca87bd47acb7400813bd7160 commit fdbf7cab91ae9ae7ca87bd47acb7400813bd7160 Author: Elyes Haouas AuthorDate: 2024-04-29 02:55:30 +0000 Commit: Warner Losh CommitDate: 2024-04-29 03:24:46 +0000 bluetooth: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0]) Pull Request: https://github.com/freebsd/freebsd-src/pull/888 Signed-off-by: Elyes Haouas --- usr.sbin/bluetooth/bthidcontrol/sdp.c | 6 +++--- usr.sbin/bluetooth/bthidd/kbd.c | 5 +++-- usr.sbin/bluetooth/hccontrol/hccontrol.c | 5 +++-- usr.sbin/bluetooth/hccontrol/node.c | 7 ++++--- usr.sbin/bluetooth/sdpcontrol/search.c | 5 +++-- usr.sbin/bluetooth/sdpd/profile.c | 5 +++-- usr.sbin/bluetooth/sdpd/sar.c | 3 ++- usr.sbin/bluetooth/sdpd/srr.c | 3 ++- usr.sbin/bluetooth/sdpd/ssr.c | 3 ++- 9 files changed, 25 insertions(+), 17 deletions(-) diff --git a/usr.sbin/bluetooth/bthidcontrol/sdp.c b/usr.sbin/bluetooth/bthidcontrol/sdp.c index dc83229f080c..4754744a866a 100644 --- a/usr.sbin/bluetooth/bthidcontrol/sdp.c +++ b/usr.sbin/bluetooth/bthidcontrol/sdp.c @@ -30,7 +30,7 @@ * $Id: sdp.c,v 1.3 2004/02/17 22:14:57 max Exp $ */ -#include +#include #include #include #define L2CAP_SOCKET_CHECKED @@ -79,10 +79,10 @@ SDP_ATTR_RANGE( 0x0209, /* HIDBatteryPower */ SDP_ATTR_RANGE( 0x020d, /* HIDNormallyConnectable */ 0x020d) }; -#define nattrs (sizeof(attrs)/sizeof(attrs[0])) +#define nattrs nitems(attrs) static sdp_attr_t values[8]; -#define nvalues (sizeof(values)/sizeof(values[0])) +#define nvalues nitems(values) static uint8_t buffer[nvalues][512]; diff --git a/usr.sbin/bluetooth/bthidd/kbd.c b/usr.sbin/bluetooth/bthidd/kbd.c index c1616c7e4bd3..a807a9b27dec 100644 --- a/usr.sbin/bluetooth/bthidd/kbd.c +++ b/usr.sbin/bluetooth/bthidd/kbd.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -319,7 +320,7 @@ static int32_t const x[] = /* Right GUI E7 */ E0PREFIX|0x5C /* E0 DC */ }; -#define xsize ((int32_t)(sizeof(x)/sizeof(x[0]))) +#define xsize (int32_t)nitems(x) /* * Get a max HID keycode (aligned) @@ -437,7 +438,7 @@ kbd_write(bitstr_t *m, int32_t fb, int32_t make, int32_t fd) int32_t i, *b, *eob, n, buf[64]; b = buf; - eob = b + sizeof(buf)/sizeof(buf[0]); + eob = b + nitems(buf); i = fb; while (i < xsize) { diff --git a/usr.sbin/bluetooth/hccontrol/hccontrol.c b/usr.sbin/bluetooth/hccontrol/hccontrol.c index c1ce016e6246..bd63c9aff6ec 100644 --- a/usr.sbin/bluetooth/hccontrol/hccontrol.c +++ b/usr.sbin/bluetooth/hccontrol/hccontrol.c @@ -33,6 +33,7 @@ #define L2CAP_SOCKET_CHECKED #include #include +#include #include #include #include @@ -153,11 +154,11 @@ socket_open(char const *node) (void * const) &filter, sizeof(filter)) < 0) err(4, "Could not setsockopt()"); - size = (sizeof(mib)/sizeof(mib[0])); + size = nitems(mib); if (sysctlnametomib("net.bluetooth.hci.command_timeout",mib,&size) < 0) err(5, "Could not sysctlnametomib()"); - if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), + if (sysctl(mib, nitems(mib), (void *) &timeout, &size, NULL, 0) < 0) err(6, "Could not sysctl()"); diff --git a/usr.sbin/bluetooth/hccontrol/node.c b/usr.sbin/bluetooth/hccontrol/node.c index b100900f527d..61b60ba95db5 100644 --- a/usr.sbin/bluetooth/hccontrol/node.c +++ b/usr.sbin/bluetooth/hccontrol/node.c @@ -31,6 +31,7 @@ */ #include +#include #define L2CAP_SOCKET_CHECKED #include #include @@ -160,7 +161,7 @@ hci_read_node_features(int s, int argc, char **argv) return (ERROR); fprintf(stdout, "Features: "); - for (n = 0; n < sizeof(r.features)/sizeof(r.features[0]); n++) + for (n = 0; n < nitems(r.features); n++) fprintf(stdout, "%#02x ", r.features[n]); fprintf(stdout, "\n%s\n", hci_features2str(r.features, buffer, sizeof(buffer))); @@ -243,8 +244,8 @@ hci_read_neighbor_cache(int s, int argc, char **argv) for (n = 0; n < r.num_entries; n++) { uint8_t addrtype = r.entries[n].addrtype; - if(addrtype >= sizeof(addrtype2str)/sizeof(addrtype2str[0])) - addrtype = sizeof(addrtype2str)/sizeof(addrtype2str[0]) - 1; + if(addrtype >= nitems(addrtype2str)) + addrtype = nitems(addrtype2str) - 1; fprintf(stdout, "%1s %-17.17s " \ "%02x %02x %02x %02x %02x %02x %02x %02x " \ diff --git a/usr.sbin/bluetooth/sdpcontrol/search.c b/usr.sbin/bluetooth/sdpcontrol/search.c index 94c34828a949..2a4b2468c7f7 100644 --- a/usr.sbin/bluetooth/sdpcontrol/search.c +++ b/usr.sbin/bluetooth/sdpcontrol/search.c @@ -30,6 +30,7 @@ * $Id: search.c,v 1.2 2003/09/08 17:35:15 max Exp $ */ +#include #include #define L2CAP_SOCKET_CHECKED #include @@ -51,7 +52,7 @@ static uint32_t attrs[] = SDP_ATTR_RANGE( SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST) }; -#define attrs_len (sizeof(attrs)/sizeof(attrs[0])) +#define attrs_len nitems(attrs) /* Buffer for the attributes */ #define NRECS 25 /* request this much records from the SDP server */ @@ -60,7 +61,7 @@ static uint8_t buffer[NRECS * attrs_len][BSIZE]; /* SDP attributes */ static sdp_attr_t values[NRECS * attrs_len]; -#define values_len (sizeof(values)/sizeof(values[0])) +#define values_len nitems(values) /* * Print Service Class ID List diff --git a/usr.sbin/bluetooth/sdpd/profile.c b/usr.sbin/bluetooth/sdpd/profile.c index 3c6ada6871c7..e6d81f8ef4b1 100644 --- a/usr.sbin/bluetooth/sdpd/profile.c +++ b/usr.sbin/bluetooth/sdpd/profile.c @@ -32,6 +32,7 @@ * $Id: profile.c,v 1.6 2004/01/13 19:31:54 max Exp $ */ +#include #include #define L2CAP_SOCKET_CHECKED #include @@ -77,7 +78,7 @@ profile_get_descriptor(uint16_t uuid) int32_t i; - for (i = 0; i < sizeof(profiles)/sizeof(profiles[0]); i++) + for (i = 0; i < nitems(profiles); i++) if (profiles[i]->uuid == uuid) return (profiles[i]); @@ -444,7 +445,7 @@ bnep_profile_create_protocol_descriptor_list( }; uint16_t i, psm, version = 0x0100, - nptypes = sizeof(ptype)/sizeof(ptype[0]), + nptypes = nitems(ptype), nptypes_size = nptypes * 3; if (datalen != 2 || 18 + nptypes_size > 255 || diff --git a/usr.sbin/bluetooth/sdpd/sar.c b/usr.sbin/bluetooth/sdpd/sar.c index 0470109ebc07..68193b567fd3 100644 --- a/usr.sbin/bluetooth/sdpd/sar.c +++ b/usr.sbin/bluetooth/sdpd/sar.c @@ -30,6 +30,7 @@ * $Id: sar.c,v 1.2 2004/01/08 23:46:51 max Exp $ */ +#include #include #include #include @@ -304,7 +305,7 @@ server_send_service_attribute_response(server_p srv, int32_t fd) iov[3].iov_len = 1 + cs[0]; do { - size = writev(fd, (struct iovec const *) &iov, sizeof(iov)/sizeof(iov[0])); + size = writev(fd, (struct iovec const *) &iov, nitems(iov)); } while (size < 0 && errno == EINTR); /* Check if we have sent (or failed to sent) last response chunk */ diff --git a/usr.sbin/bluetooth/sdpd/srr.c b/usr.sbin/bluetooth/sdpd/srr.c index 8e887a4841de..b16eb25c9ea4 100644 --- a/usr.sbin/bluetooth/sdpd/srr.c +++ b/usr.sbin/bluetooth/sdpd/srr.c @@ -30,6 +30,7 @@ * $Id: srr.c,v 1.1 2004/01/13 01:54:39 max Exp $ */ +#include #include #include #include @@ -129,7 +130,7 @@ server_send_service_register_response(server_p srv, int32_t fd) iov[1].iov_len = srv->fdidx[fd].rsp_size; do { - size = writev(fd, (struct iovec const *) &iov, sizeof(iov)/sizeof(iov[0])); + size = writev(fd, (struct iovec const *) &iov, nitems(iov)); } while (size < 0 && errno == EINTR); srv->fdidx[fd].rsp_cs = 0; diff --git a/usr.sbin/bluetooth/sdpd/ssr.c b/usr.sbin/bluetooth/sdpd/ssr.c index c6b3a1f65fe1..1a29dde97ee5 100644 --- a/usr.sbin/bluetooth/sdpd/ssr.c +++ b/usr.sbin/bluetooth/sdpd/ssr.c @@ -30,6 +30,7 @@ * $Id: ssr.c,v 1.5 2004/01/13 01:54:39 max Exp $ */ +#include #include #include #include @@ -269,7 +270,7 @@ server_send_service_search_response(server_p srv, int32_t fd) iov[3].iov_len = 1 + cs[0]; do { - size = writev(fd, (struct iovec const *) &iov, sizeof(iov)/sizeof(iov[0])); + size = writev(fd, (struct iovec const *) &iov, nitems(iov)); } while (size < 0 && errno == EINTR); /* Check if we have sent (or failed to sent) last response chunk */