Don't force gcc as host compiler + fix clang warnings

On MacOS, gcc is a symlink for clang.

Patch gets rid of the warnings produced by clang,
when it is set as HOSTCC, and fixes voicetools
compilation on MacOS when calling make voicetools
from the simulator directory.

lua rb_defines_helper:
format specifies type 'int' but the argument has
type 'long'

codecs: opus / speex (LOGF):
format '%ld' expects argument of type 'long int',
but argument 7 has type 'off_t'

gigabeat:
variable 'size' set but not used

rdf2binary:
a function declaration without a prototype is
deprecated in all versions of C

rbspeexdec:
passing 'unsigned char *' to parameter of type
'char *' converts between pointers to integer
types where one is of the unique plain 'char'
type and the other is not

hmac-sha1.c
defining a type within 'offsetof' is a Clang
extension

Change-Id: I90539906698868f9589650585d865aee9f7e8539
This commit is contained in:
Christian Soffke 2024-12-13 18:31:27 +01:00
parent a86b1999d0
commit 727c800c0d
8 changed files with 25 additions and 33 deletions

View file

@ -161,7 +161,7 @@ foreach my $define (@sorted_defines)
} }
elsif(@$define{'value'} =~ /^[0-9]+$/) #number elsif(@$define{'value'} =~ /^[0-9]+$/) #number
{ {
printf "\tprintf(\"%s[\\\"%%s\\\"] = %%d\\n\", stringify(%s), %s);\n", $lua_table, @$define{'name'}, @$define{'name'}; printf "\tprintf(\"%s[\\\"%%s\\\"] = %%ld\\n\", stringify(%s), (long) %s);\n", $lua_table, @$define{'name'}, @$define{'name'};
} }
else #might be a string but we don't know since the macro isn't expanded far enough else #might be a string but we don't know since the macro isn't expanded far enough
{ {
@ -199,7 +199,7 @@ foreach my $define (@sorted_defines)
} }
elsif ($var =~$num_regex) #it must be a number elsif ($var =~$num_regex) #it must be a number
{ {
printf "\tprintf(\"%s[\\\"%%s\\\"] = %%d\\n\", stringify(%s), %s);\n", $lua_table, @$define{'name'}, @$define{'name'}; printf "\tprintf(\"%s[\\\"%%s\\\"] = %%ld\\n\", stringify(%s), (long) %s);\n", $lua_table, @$define{'name'}, @$define{'name'};
} }
else { warn "Skipping ".@$define{'name'}." indeterminate macro type\n"; } else { warn "Skipping ".@$define{'name'}." indeterminate macro type\n"; }
} }

View file

@ -70,7 +70,7 @@ static int seek_ogg_page(uint64_t filepos)
break; break;
if (memcmp(buf, synccode, sizeof(buf)) == 0) { if (memcmp(buf, synccode, sizeof(buf)) == 0) {
ci->seek_buffer(ci->curpos - sizeof(buf)); ci->seek_buffer(ci->curpos - sizeof(buf));
LOGF("next page %ld", ci->curpos); LOGF("next page %jd", (intmax_t) ci->curpos);
return 1; return 1;
} else } else
ci->seek_buffer(ci->curpos - (sizeof(buf) - 1)); ci->seek_buffer(ci->curpos - (sizeof(buf) - 1));
@ -91,7 +91,7 @@ static int seek_opus_tags(void)
break; break;
if (memcmp(buf, synccode, sizeof(buf)) == 0) { if (memcmp(buf, synccode, sizeof(buf)) == 0) {
ci->seek_buffer(ci->curpos - sizeof(buf)); ci->seek_buffer(ci->curpos - sizeof(buf));
LOGF("OpusTags %ld", ci->curpos); LOGF("OpusTags %jd", (intmax_t) ci->curpos);
return 1; return 1;
} else } else
ci->seek_buffer(ci->curpos - (sizeof(buf) - 1)); ci->seek_buffer(ci->curpos - (sizeof(buf) - 1));

View file

@ -167,7 +167,7 @@ static spx_int64_t seek_backwards(spx_ogg_sync_state *oy, spx_ogg_page *og,
offset = ret; offset = ret;
continue; continue;
} }
} else if (ret == -3) } else if (ret == -3)
return(-3); return(-3);
else if (ret<=0) else if (ret<=0)
break; break;
@ -187,8 +187,8 @@ static int speex_seek_page_granule(spx_int64_t pos, spx_int64_t curpos,
spx_ogg_sync_state *oy, spx_ogg_sync_state *oy,
spx_int64_t headerssize) spx_int64_t headerssize)
{ {
/* TODO: Someone may want to try to implement seek to packet, /* TODO: Someone may want to try to implement seek to packet,
instead of just to page (should be more accurate, not be any instead of just to page (should be more accurate, not be any
faster) */ faster) */
spx_int64_t crofs; spx_int64_t crofs;
@ -222,9 +222,9 @@ static int speex_seek_page_granule(spx_int64_t pos, spx_int64_t curpos,
offset = get_next_page(oy,&og,-1); offset = get_next_page(oy,&og,-1);
if (offset < 0) { /* could not find new page,use old offset */ if (offset < 0) { /* could not find new page,use old offset */
LOGF("Seek/guess/fault:%lld->-<-%d,%lld:%lld,%d,%ld,%d\n", LOGF("Seek/guess/fault:%lld->-<-%d,%lld:%lld,%d,%jd,%d\n",
(long long int)curpos,0, (long long int)pos, (long long int)curpos,0, (long long int)pos,
(long long int)offset,0,ci->curpos,/*stream_length*/0); (long long int)offset,0, (intmax_t) ci->curpos,/*stream_length*/0);
curoffset = *curbyteoffset; curoffset = *curbyteoffset;
@ -233,9 +233,9 @@ static int speex_seek_page_granule(spx_int64_t pos, spx_int64_t curpos,
spx_ogg_sync_reset(oy); spx_ogg_sync_reset(oy);
} else { } else {
if (spx_ogg_page_granulepos(&og) == 0 && pos > 5000) { if (spx_ogg_page_granulepos(&og) == 0 && pos > 5000) {
LOGF("SEEK/guess/fault:%lld->-<-%lld,%lld:%lld,%d,%ld,%d\n", LOGF("SEEK/guess/fault:%lld->-<-%lld,%lld:%lld,%d,%jd,%d\n",
(long long int)curpos,(long long int)spx_ogg_page_granulepos(&og), (long long int)curpos,(long long int)spx_ogg_page_granulepos(&og),
(long long int)pos, (long long int)offset,0,ci->curpos,/*stream_length*/0); (long long int)pos, (long long int)offset,0, (intmax_t) ci->curpos,/*stream_length*/0);
curoffset = *curbyteoffset; curoffset = *curbyteoffset;
@ -271,7 +271,7 @@ static int speex_seek_page_granule(spx_int64_t pos, spx_int64_t curpos,
lastgranule = spx_ogg_page_granulepos(&og); lastgranule = spx_ogg_page_granulepos(&og);
if ( ((lastgranule - (avgpagelen/4)) < pos && ( lastgranule + if ( ((lastgranule - (avgpagelen/4)) < pos && ( lastgranule +
avgpagelen + (avgpagelen / 4)) > pos) || avgpagelen + (avgpagelen / 4)) > pos) ||
lastgranule > pos) { lastgranule > pos) {
@ -339,7 +339,7 @@ static void *process_header(spx_ogg_packet *op,
DEBUGF("Too old bitstream"); DEBUGF("Too old bitstream");
return NULL; return NULL;
} }
st = speex_decoder_init(mode); st = speex_decoder_init(mode);
if (!st){ if (!st){
DEBUGF("Decoder init failed"); DEBUGF("Decoder init failed");

9
tools/configure vendored
View file

@ -16,9 +16,6 @@ LDOPTS=""
GLOBAL_LDOPTS="" GLOBAL_LDOPTS=""
LDMAP_OPT="-Map" LDMAP_OPT="-Map"
HOSTCC=gcc
HOSTAR=ar
extradefines="" extradefines=""
use_logf="#undef ROCKBOX_HAS_LOGF" use_logf="#undef ROCKBOX_HAS_LOGF"
use_bootchart="#undef DO_BOOTCHART" use_bootchart="#undef DO_BOOTCHART"
@ -398,9 +395,7 @@ simcc () {
if $CC --version | grep -q "clang"; then if $CC --version | grep -q "clang"; then
echo "[Warning] Clang compiler ($CC) in your path is unsupported. Trying gcc-14." echo "[Warning] Clang compiler ($CC) in your path is unsupported. Trying gcc-14."
CC=gcc-14 CC=gcc-14
HOSTCC=gcc-14
AR=gcc-ar-14 AR=gcc-ar-14
HOSTAR=gcc-ar-14
CPP=cpp-14 CPP=cpp-14
fi fi
LDOPTS="$LDOPTS -ldl" LDOPTS="$LDOPTS -ldl"
@ -4612,8 +4607,8 @@ else
fi fi
# figure out the full path to the various commands if possible # figure out the full path to the various commands if possible
HOSTCC=`findtool ${HOSTCC} --lit` HOSTCC=`findtool gcc --lit`
HOSTAR=`findtool ${HOSTAR} --lit` HOSTAR=`findtool ar --lit`
CC=`findtool ${CC} --lit` CC=`findtool ${CC} --lit`
CPP=`findtool ${CPP} --lit` CPP=`findtool ${CPP} --lit`
LD=`findtool ${LD} --lit` LD=`findtool ${LD} --lit`

View file

@ -52,7 +52,6 @@ static FILE * openoutfile( const char * filename )
int gigabeat_code(char *infile, char *outfile) int gigabeat_code(char *infile, char *outfile)
{ {
FILE *in, *out; FILE *in, *out;
unsigned long size = 0;
unsigned long bytes_read; unsigned long bytes_read;
unsigned char buf[4]; unsigned char buf[4];
unsigned long data; unsigned long data;
@ -66,14 +65,12 @@ int gigabeat_code(char *infile, char *outfile)
/* Read in little-endian */ /* Read in little-endian */
data = le2int(buf); data = le2int(buf);
data = data ^ key; data = data ^ key;
key = key + (key << 1); key = key + (key << 1);
key = key + 0x19751217; key = key + 0x19751217;
size += bytes_read;
/* Write out little-endian */ /* Write out little-endian */
int2le(data, buf); int2le(data, buf);

View file

@ -225,7 +225,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
if (len >= 64) if (len >= 64)
{ {
#if !_STRING_ARCH_unaligned #if !_STRING_ARCH_unaligned
# define alignof(type) offsetof (struct { char c; type x; }, x) # define alignof(type) __alignof__(type)
# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
if (UNALIGNED_P (buffer)) if (UNALIGNED_P (buffer))
while (len > 64) while (len > 64)

View file

@ -17,13 +17,13 @@
* KIND, either express or implied. * KIND, either express or implied.
* *
***************************************************************************/ ***************************************************************************/
#include <speex/speex.h> #include <speex/speex.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "string.h" #include "string.h"
#include "rbspeex.h" #include "rbspeex.h"
#define USAGE_TEXT \ #define USAGE_TEXT \
"Usage: rbspeexdec infile outfile\n"\ "Usage: rbspeexdec infile outfile\n"\
"rbspeexdec outputs mono 16 bit 16 kHz WAV files.\n"\ "rbspeexdec outputs mono 16 bit 16 kHz WAV files.\n"\
@ -50,13 +50,13 @@ int main(int argc, char **argv)
/* Rockbox speex streams are always assumed to be WB */ /* Rockbox speex streams are always assumed to be WB */
st = speex_decoder_init(&speex_wb_mode); st = speex_decoder_init(&speex_wb_mode);
/* Set the perceptual enhancement on (is default, but doesn't hurt) */ /* Set the perceptual enhancement on (is default, but doesn't hurt) */
tmp = 1; tmp = 1;
speex_decoder_ctl(st, SPEEX_SET_ENH, &tmp); speex_decoder_ctl(st, SPEEX_SET_ENH, &tmp);
speex_decoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); speex_decoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead);
speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, &frame_size); speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, &frame_size);
if ((fin = fopen(argv[1], "rb")) == NULL) { if ((fin = fopen(argv[1], "rb")) == NULL) {
printf("Error: could not open input file\n"); printf("Error: could not open input file\n");
return 1; return 1;
@ -74,8 +74,8 @@ int main(int argc, char **argv)
fclose(fin); fclose(fin);
/* fill in wav header */ /* fill in wav header */
strcpy(wavhdr, "RIFF"); strcpy((char *) wavhdr, "RIFF");
strcpy(wavhdr + 8, "WAVEfmt "); strcpy((char *) wavhdr + 8, "WAVEfmt ");
put_uint_le(16, wavhdr + 16); put_uint_le(16, wavhdr + 16);
put_ushort_le(1, wavhdr + 20); /* PCM data */ put_ushort_le(1, wavhdr + 20); /* PCM data */
put_ushort_le(1, wavhdr + 22); /* mono */ put_ushort_le(1, wavhdr + 22); /* mono */
@ -83,7 +83,7 @@ int main(int argc, char **argv)
put_uint_le(16000*2, wavhdr + 28); /* chan*sr*bbs/8 */ put_uint_le(16000*2, wavhdr + 28); /* chan*sr*bbs/8 */
put_ushort_le(2, wavhdr + 32); /* chan*bps/8 */ put_ushort_le(2, wavhdr + 32); /* chan*bps/8 */
put_ushort_le(16, wavhdr + 34); /* bits per sample */ put_ushort_le(16, wavhdr + 34); /* bits per sample */
strcpy(wavhdr + 36, "data"); strcpy((char *) wavhdr + 36, "data");
fwrite(wavhdr, 1, 44, fout); /* write header */ fwrite(wavhdr, 1, 44, fout); /* write header */
/* make bit buffer use our own buffer */ /* make bit buffer use our own buffer */
speex_bits_set_bit_buffer(&bits, indata, insize); speex_bits_set_bit_buffer(&bits, indata, insize);

View file

@ -58,7 +58,7 @@ long reverse (long N) {
} }
int main() int main(void)
{ {
FILE *in, *idx_out, *desc_out; FILE *in, *idx_out, *desc_out;
struct word w; struct word w;