Skip to content

Commit b2a1f5e

Browse files
committed
fix -Wshadow and -Wimplicit-int-conversion warnings
1 parent 993c8ed commit b2a1f5e

9 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/crt/lltof.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
float _lltof_c(long long x)
66
{
7-
uint8_t exponent = x ? __builtin_clrsbll(x) : LLONG_WIDTH - 1;
7+
uint8_t exponent = x ? ((uint8_t)__builtin_clrsbll(x)) : LLONG_WIDTH - 1;
88
if (exponent >= LLONG_WIDTH - LONG_WIDTH) {
99
return (float)((long)x);
1010
}

src/crt/ulltof.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
float _ulltof_c(unsigned long long x)
66
{
7-
uint8_t exponent = x ? __builtin_clzll(x) : ULLONG_WIDTH;
7+
uint8_t exponent = x ? ((uint8_t)__builtin_clzll(x)) : ULLONG_WIDTH;
88
if (exponent >= ULLONG_WIDTH - ULONG_WIDTH) {
99
return (float)((unsigned long)x);
1010
}

src/libc/fgets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ char* __attribute__((weak)) fgets(char *__restrict str, int num, FILE *__restric
1818
{
1919
break;
2020
}
21-
*p++ = c;
21+
*p++ = (char)c;
2222
if (c == '\n')
2323
{
2424
break;

src/libc/float64_rounding.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ long long llroundl(long double x) {
7575
FE_UPWARD == softfloat_round_max)
7676

7777
// assumes fenv.h macros match softfloat_roundingModes
78-
#define GET_FENV_SOFTFLOAT_ROUNDING() (fegetround())
78+
#define GET_FENV_SOFTFLOAT_ROUNDING() ((uint_fast8_t)fegetround())
7979

8080
#else
8181
static uint_fast8_t GET_FENV_SOFTFLOAT_ROUNDING(void) {

src/libc/fread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ size_t __attribute__((weak)) fread(void *ptr, size_t size, size_t count, FILE *_
2424
{
2525
break;
2626
}
27-
*p++ = c;
27+
*p++ = (char)c;
2828
}
2929

3030
return count;

src/libc/gmtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct tm *gmtime(const time_t *tp)
8282
tm2.tm_min++;
8383
}
8484

85-
tm2.tm_sec = t;
85+
tm2.tm_sec = (int)t;
8686

8787
return &tm2;
8888
}

src/libc/printf/nanoprintf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
static void npf_putc_std(int c, void *ctx) {
2020
(void)ctx;
21-
outchar(c);
21+
outchar((char)c);
2222
}
2323

2424
static void npf_fputc_std(int c, void *ctx) {

src/libc/printf/nanoprintf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,9 @@ static npf_cnt_putc_ctx_t pc_cnt;
766766
#endif
767767

768768
static void npf_putc_cnt(int c, void *ctx) {
769-
npf_cnt_putc_ctx_t *pc_cnt = (npf_cnt_putc_ctx_t *)ctx;
770-
++pc_cnt->n;
771-
pc_cnt->pc(c, pc_cnt->ctx); // sibling-call optimization
769+
npf_cnt_putc_ctx_t *pc_putc_cnt = (npf_cnt_putc_ctx_t *)ctx;
770+
++pc_putc_cnt->n;
771+
pc_putc_cnt->pc(c, pc_putc_cnt->ctx); // sibling-call optimization
772772
}
773773

774774
#ifdef NANOPRINTF_STATIC_GLOBALS

src/libc/strftime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ size_t strftime(char *__restrict s, size_t n, const char *__restrict f, const st
8181

8282
while (s + 1 < e && *f)
8383
{
84-
int c = *f++;
84+
char c = *f++;
8585
int val;
8686

8787
if (c != '%')

0 commit comments

Comments
 (0)