git: 53314e34d5e8 - main - mididump(1): Use nitems()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 19 Oct 2024 14:34:41 UTC
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=53314e34d5e8e7f781ab990805b22f7a56bc0580 commit 53314e34d5e8e7f781ab990805b22f7a56bc0580 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-10-19 14:34:27 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2024-10-19 14:34:27 +0000 mididump(1): Use nitems() Reported by: kevans Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj, emaste Differential Revision: https://reviews.freebsd.org/D47191 --- usr.bin/mididump/mididump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/mididump/mididump.c b/usr.bin/mididump/mididump.c index 16bd775f10d4..8ebcce547ac4 100644 --- a/usr.bin/mididump/mididump.c +++ b/usr.bin/mididump/mididump.c @@ -28,6 +28,7 @@ * SUCH DAMAGE. */ +#include <sys/param.h> #include <sys/soundcard.h> #include <err.h> @@ -39,7 +40,6 @@ #include <string.h> #include <unistd.h> -#define ARRLEN(x) (sizeof(x) / sizeof(x[0])) #define NOTE2OCTAVE(n) (n / 12 - 1) #define NOTE2FREQ(n) (440 * pow(2.0f, ((float)n - 69) / 12)) #define CHAN_MASK 0x0f @@ -189,7 +189,7 @@ main(int argc, char *argv[]) case 0x90 ... 0x9f: b1 = read_byte(fd); b2 = read_byte(fd); - pn = ¬es[b1 % ARRLEN(notes)]; + pn = ¬es[b1 % nitems(notes)]; snprintf(buf, sizeof(buf), "%s%d", pn->name, NOTE2OCTAVE(b1)); if (pn->alt != NULL) { @@ -211,7 +211,7 @@ main(int argc, char *argv[]) case 0xb0 ... 0xbf: b1 = read_byte(fd); b2 = read_byte(fd); - if (b1 > ARRLEN(ctls) - 1) + if (b1 > nitems(ctls) - 1) break; printf("Control/Mode change channel=%d, " "control=%d (%s), value=%d",