Skip to content

Commit

Permalink
Fix warning in GOTCHA
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTheBear committed Dec 10, 2024
1 parent 1e3a7d5 commit 2e92f1a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ext/GOTCHA/src/libc_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ int gotcha_int_printf(int fd, const char *format, ...) {
int buffer_pos = 0;
int char_width, short_width, long_width, long_long_width, size_width;
int num_printed = 0;
char buffer[4096];
char buffer[4096] = {'\0'};

va_start(args, format);
while (*str) {
Expand Down Expand Up @@ -426,8 +426,8 @@ int gotcha_int_printf(int fd, const char *format, ...) {
}

if (*str == 'd' || *str == 'i') {
signed long val;
char numstr[64];
signed long val = 0;
char numstr[64] = {'\0'};
if (char_width)
val = (signed long)(signed char)va_arg(args, signed int);
else if (short_width)
Expand All @@ -444,8 +444,8 @@ int gotcha_int_printf(int fd, const char *format, ...) {
add_to_buffer(numstr, fd, &buffer_pos, buffer, sizeof(buffer),
&num_printed, 1);
} else if (*str == 'u') {
unsigned long val;
char numstr[64];
unsigned long val = 0;
char numstr[64] = {'\0'};
if (char_width)
val = (unsigned long)(unsigned char)va_arg(args, unsigned int);
else if (short_width)
Expand All @@ -462,8 +462,8 @@ int gotcha_int_printf(int fd, const char *format, ...) {
add_to_buffer(numstr, fd, &buffer_pos, buffer, sizeof(buffer),
&num_printed, 1);
} else if (*str == 'x' || *str == 'X' || *str == 'p') {
unsigned long val;
char numstr[64];
unsigned long val = 0;
char numstr[64] = {'\0'};
if (*str != 'p') {
if (char_width)
val = (unsigned long)(unsigned char)va_arg(args, unsigned int);
Expand All @@ -486,7 +486,7 @@ int gotcha_int_printf(int fd, const char *format, ...) {
add_to_buffer(numstr, fd, &buffer_pos, buffer, sizeof(buffer),
&num_printed, 1);
} else if (*str == 'c') {
char cbuf[2];
char cbuf[2] = {'\0'};
cbuf[0] = (unsigned char)va_arg(args, unsigned int);
cbuf[1] = '\0';
add_to_buffer(cbuf, fd, &buffer_pos, buffer, sizeof(buffer), &num_printed,
Expand All @@ -499,7 +499,7 @@ int gotcha_int_printf(int fd, const char *format, ...) {
add_to_buffer("%", fd, &buffer_pos, buffer, sizeof(buffer), &num_printed,
1);
} else {
char s[3];
char s[3] = {'\0'};
s[0] = '%';
s[1] = *str;
s[2] = '\0';
Expand Down

0 comments on commit 2e92f1a

Please sign in to comment.