Module Name: src Committed By: martin Date: Fri Aug 23 17:15:11 UTC 2024
Modified Files: src/usr.bin/audio/common [netbsd-10]: wav.c src/usr.bin/audio/record [netbsd-10]: record.c Log Message: Pull up following revision(s) (requested by mrg in ticket #797): usr.bin/audio/common/wav.c: revision 1.23 usr.bin/audio/record/record.c: revision 1.59 fix some sizeof() confusion. using "const char search[4]" as a function parameter means that "search" is actually a pointer type so "sizeof search" returns 8 on 64-bit platforms. i mis-read this and used "sizeof *search" which is always 1, noted by rillig. instead of trying to avoid writing "4" twice, put it in a define and use that in various places instead. annoying. match message & conversion function name properly. probably should make this into an array with two members. To generate a diff of this commit: cvs rdiff -u -r1.15.8.2 -r1.15.8.3 src/usr.bin/audio/common/wav.c cvs rdiff -u -r1.56.2.1 -r1.56.2.2 src/usr.bin/audio/record/record.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/audio/common/wav.c diff -u src/usr.bin/audio/common/wav.c:1.15.8.2 src/usr.bin/audio/common/wav.c:1.15.8.3 --- src/usr.bin/audio/common/wav.c:1.15.8.2 Mon Mar 25 15:09:38 2024 +++ src/usr.bin/audio/common/wav.c Fri Aug 23 17:15:10 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: wav.c,v 1.15.8.2 2024/03/25 15:09:38 martin Exp $ */ +/* $NetBSD: wav.c,v 1.15.8.3 2024/08/23 17:15:10 martin Exp $ */ /* * Copyright (c) 2002, 2009, 2013, 2015, 2019, 2024 Matthew R. Green @@ -33,7 +33,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: wav.c,v 1.15.8.2 2024/03/25 15:09:38 martin Exp $"); +__RCSID("$NetBSD: wav.c,v 1.15.8.3 2024/08/23 17:15:10 martin Exp $"); #endif @@ -91,8 +91,10 @@ wav_enc_from_val(int encoding) * WAV format helpers */ +#define RIFFNAMELEN 4 + static bool -find_riff_chunk(const char search[4], size_t *remainp, char **wherep, uint32_t *partlen) +find_riff_chunk(const char *search, size_t *remainp, char **wherep, uint32_t *partlen) { wav_audioheaderpart part; @@ -116,7 +118,7 @@ find_riff_chunk(const char search[4], si emsg = " (odd length, adjusted)"; len += 1; } - if (strncmp(part.name, search, sizeof *search) == 0) { + if (strncmp(part.name, search, RIFFNAMELEN) == 0) { *partlen = len; if (verbose > 1) fprintf(stderr, "Found part %.04s length %d%s\n", @@ -148,10 +150,10 @@ audio_wav_parse_hdr(void *hdr, size_t sz uint32_t len = 0; u_int16_t fmttag; static const char - strfmt[4] = "fmt ", - strRIFF[4] = "RIFF", - strWAVE[4] = "WAVE", - strdata[4] = "data"; + strfmt[RIFFNAMELEN] = "fmt ", + strRIFF[RIFFNAMELEN] = "RIFF", + strWAVE[RIFFNAMELEN] = "WAVE", + strdata[RIFFNAMELEN] = "data"; bool found; if (sz < 32) Index: src/usr.bin/audio/record/record.c diff -u src/usr.bin/audio/record/record.c:1.56.2.1 src/usr.bin/audio/record/record.c:1.56.2.2 --- src/usr.bin/audio/record/record.c:1.56.2.1 Tue Mar 12 10:04:23 2024 +++ src/usr.bin/audio/record/record.c Fri Aug 23 17:15:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: record.c,v 1.56.2.1 2024/03/12 10:04:23 martin Exp $ */ +/* $NetBSD: record.c,v 1.56.2.2 2024/08/23 17:15:11 martin Exp $ */ /* * Copyright (c) 1999, 2002, 2003, 2005, 2010 Matthew R. Green @@ -32,7 +32,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: record.c,v 1.56.2.1 2024/03/12 10:04:23 martin Exp $"); +__RCSID("$NetBSD: record.c,v 1.56.2.2 2024/08/23 17:15:11 martin Exp $"); #endif @@ -322,9 +322,9 @@ main(int argc, char *argv[]) s = "change sign (little-endian, 32 bit)"; else if (conv_func == change_sign16_swap_bytes_be) s = "change sign & swap bytes (big-endian, 16 bit)"; - else if (conv_func == change_sign24_swap_bytes_le) + else if (conv_func == change_sign16_swap_bytes_le) s = "change sign & swap bytes (little-endian, 16 bit)"; - else if (conv_func == change_sign16_swap_bytes_be) + else if (conv_func == change_sign24_swap_bytes_be) s = "change sign & swap bytes (big-endian, 24 bit)"; else if (conv_func == change_sign24_swap_bytes_le) s = "change sign & swap bytes (little-endian, 24 bit)";