Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop DCC from complaining about it's own additions with -Wextra enabled #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions dcc_check_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static unsigned char actual_line[ACTUAL_LINE_MAX + 1];
// position to put next character in above array
static int n_actual_line;
// n bytes seen prior to those in above array
static size_t n_actual_bytes_seen;
static ssize_t n_actual_bytes_seen;
static size_t n_actual_lines_seen;

static unsigned char expected_line[ACTUAL_LINE_MAX + 2];
Expand All @@ -150,7 +150,7 @@ static void rstrip_line(unsigned char *line, int last_byte_index);
static void __dcc_compare_output(unsigned char *actual, size_t size) {
int expected_bytes_in_line = get_next_expected_line();
debug_printf(2, " __dcc_compare_output() n_actual_lines_seen=%d\n", n_actual_lines_seen);
for (int i = 0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
if (max_stdout_bytes && n_actual_line + n_actual_bytes_seen > max_stdout_bytes) {
n_actual_lines_seen++;
actual_line[n_actual_line] = '\0';
Expand Down Expand Up @@ -310,13 +310,13 @@ static void __dcc_compare_output_error(char *reason, int actual_column, int expe
snprintf(buffer[3], sizeof buffer[3], "DCC_N_ACTUAL_BYTES_SEEN=%zu", n_actual_bytes_seen);
snprintf(buffer[4], sizeof buffer[4], "DCC_ACTUAL_COLUMN=%d", actual_column);
snprintf(buffer[5], sizeof buffer[5], "DCC_EXPECTED_COLUMN=%d", expected_column);
for (int i = 0; i < sizeof buffer/sizeof buffer[0]; i++)
for (unsigned long int i = 0; i < sizeof buffer/sizeof buffer[0]; i++)
putenvd(buffer[i]);

char line_buffer[2][128 + ACTUAL_LINE_MAX];
snprintf(line_buffer[0], sizeof line_buffer[0], "DCC_ACTUAL_LINE=%s", actual_line);
snprintf(line_buffer[1], sizeof line_buffer[1], "DCC_EXPECTED_LINE=%s", expected_line);
for (int i = 0; i < sizeof line_buffer/sizeof line_buffer[0]; i++)
for (unsigned long int i = 0; i < sizeof line_buffer/sizeof line_buffer[0]; i++)
putenvd(line_buffer[i]);
_explain_error();
}
Expand Down Expand Up @@ -358,4 +358,3 @@ static int getenv_boolean(const char *name, int default_value) {
return value ? !strchr("0fFnN", *value) : default_value;
}
#endif

6 changes: 4 additions & 2 deletions dcc_util.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

static void launch_valgrind(int argc, char *argv[], char *envp[]) {
(void) envp;
debug_printf(2, "command=%s\n", "__MONITOR_VALGRIND__");
#if __N_SANITIZERS__ > 1
extern FILE *__real_popen(const char *command, const char *type);
Expand Down Expand Up @@ -128,6 +129,7 @@ void __asan_on_error() {

// intercept ASAN explanation
void _Unwind_Backtrace(void *a, ...) {
(void) a;
debug_printf(2, "_Unwind_Backtrace\n");
_explain_error();
}
Expand Down Expand Up @@ -170,7 +172,7 @@ void __ubsan_on_report(void) {
snprintf(buffer[3], sizeof buffer[3], "DCC_UBSAN_ERROR_LINE=%u", OutLine);
snprintf(buffer[4], sizeof buffer[4], "DCC_UBSAN_ERROR_COL=%u", OutCol);
snprintf(buffer[5], sizeof buffer[5], "DCC_UBSAN_ERROR_MEMORYADDR=%s", OutMemoryAddr);
for (int i = 0; i < sizeof buffer/sizeof buffer[0]; i++)
for (unsigned long int i = 0; i < sizeof buffer/sizeof buffer[0]; i++)
putenv(buffer[i]);
#endif
_explain_error();
Expand Down Expand Up @@ -353,7 +355,7 @@ static int debug_printf(int level, const char *format, ...) {
#include <spawn.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <unistd.h>

int __real_posix_spawn(pid_t *pid, const char *path,
const posix_spawn_file_actions_t *file_actions,
Expand Down