From 13d85b14cd56e8ee78fc40ef712175d9bf8c58f7 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 16 Jun 2022 12:25:01 -0700 Subject: sbcenc: Fix build warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following warnings: In file included from /usr/include/stdio.h:894, from src/sbcenc.c:30: In function ‘fprintf’, inlined from ‘encode’ at src/sbcenc.c:160:3, inlined from ‘main’ at src/sbcenc.c:329:3: /usr/include/bits/stdio2.h:105:10: error: ‘srate’ may be used uninitialized [-Werror=maybe-uninitialized] 105 | return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 106 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ src/sbcenc.c: In function ‘main’: src/sbcenc.c:54:23: note: ‘srate’ was declared here 54 | int fd, size, srate, codesize, nframes; | ^~~~~ cc1: all warnings being treated as errors --- src/sbcenc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sbcenc.c b/src/sbcenc.c index 6f8d794..1798cde 100644 --- a/src/sbcenc.c +++ b/src/sbcenc.c @@ -89,6 +89,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint, goto done; } + srate = BE_INT(au_hdr.sample_rate); + if (!msbc) { sbc_init(&sbc, 0L); @@ -111,8 +113,6 @@ static void encode(char *filename, int subbands, int bitpool, int joint, goto done; } - srate = BE_INT(au_hdr.sample_rate); - sbc.subbands = subbands == 4 ? SBC_SB_4 : SBC_SB_8; if (BE_INT(au_hdr.channels) == 1) { @@ -141,8 +141,7 @@ static void encode(char *filename, int subbands, int bitpool, int joint, blocks == 8 ? SBC_BLK_8 : blocks == 12 ? SBC_BLK_12 : SBC_BLK_16; } else { - if (BE_INT(au_hdr.sample_rate) != 16000 || - BE_INT(au_hdr.channels) != 1) { + if (srate != 16000 || BE_INT(au_hdr.channels) != 1) { fprintf(stderr, "mSBC requires 16 bits, 16kHz, mono " "input\n"); goto done; -- cgit v1.2.1