Squelch some more warnings on Linux

This commit is contained in:
ridiculousfish 2014-04-27 18:27:34 -07:00
parent fb89c762fc
commit 4948508277
8 changed files with 30 additions and 18 deletions

View file

@ -3622,8 +3622,6 @@ static int builtin_history(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_ERROR;
}
#pragma mark Simulator
int builtin_parse(parser_t &parser, wchar_t **argv)
{
struct sigaction act;

View file

@ -716,6 +716,18 @@ void print_stderr(const wcstring &str)
fprintf(stderr, "%ls\n", str.c_str());
}
void read_ignore(int fd, void *buff, size_t count)
{
size_t ignore __attribute__((unused));
ignore = read(fd, buff, count);
}
void write_ignore(int fd, const void *buff, size_t count)
{
size_t ignore __attribute__((unused));
ignore = write(fd, buff, count);
}
void debug_safe(int level, const char *msg, const char *param1, const char *param2, const char *param3, const char *param4, const char *param5, const char *param6, const char *param7, const char *param8, const char *param9, const char *param10, const char *param11, const char *param12)
{
@ -736,7 +748,7 @@ void debug_safe(int level, const char *msg, const char *param1, const char *para
if (end == NULL)
end = cursor + strlen(cursor);
write(STDERR_FILENO, cursor, end - cursor);
write_ignore(STDERR_FILENO, cursor, end - cursor);
if (end[0] == '%' && end[1] == 's')
{
@ -745,7 +757,7 @@ void debug_safe(int level, const char *msg, const char *param1, const char *para
const char *format = params[param_idx++];
if (! format)
format = "(null)";
write(STDERR_FILENO, format, strlen(format));
write_ignore(STDERR_FILENO, format, strlen(format));
cursor = end + 2;
}
else if (end[0] == '\0')
@ -761,7 +773,7 @@ void debug_safe(int level, const char *msg, const char *param1, const char *para
}
// We always append a newline
write(STDERR_FILENO, "\n", 1);
write_ignore(STDERR_FILENO, "\n", 1);
errno = errno_old;
}

View file

@ -157,6 +157,10 @@ extern bool g_profiling_active;
*/
extern const wchar_t *program_name;
/* Variants of read() and write() that ignores return values, defeating a warning */
void read_ignore(int fd, void *buff, size_t count);
void write_ignore(int fd, const void *buff, size_t count);
/**
This macro is used to check that an input argument is not null. It
is a bit lika a non-fatal form of assert. Instead of exit-ing on
@ -182,8 +186,7 @@ extern const wchar_t *program_name;
{ \
char exit_read_buff; \
show_stackframe(); \
int ignore __attribute__((unused)); \
ignore = read( 0, &exit_read_buff, 1 ); \
read_ignore( 0, &exit_read_buff, 1 ); \
exit_without_destructors( 1 ); \
} \

View file

@ -200,9 +200,10 @@ CXXFLAGS="$CXXFLAGS -fno-exceptions"
#
# -Wall is there to keep me on my toes
# But signed comparison warnings are way too aggressive
#
CXXFLAGS="$CXXFLAGS -Wall"
CXXFLAGS="$CXXFLAGS -Wall -Wno-sign-compare"
#
# This is needed in order to get the really cool backtraces on Linux

View file

@ -1330,7 +1330,7 @@ static void test_expand()
err(L"Expansion not correctly handling literal path components in dotfiles");
}
system("rm -Rf /tmp/fish_expand_test");
if (system("rm -Rf /tmp/fish_expand_test")) err(L"rm failed");
}
static void test_fuzzy_match(void)
@ -3117,7 +3117,7 @@ static void test_highlighting(void)
// Generate the text
wcstring text;
std::vector<int> expected_colors;
std::vector<highlight_spec_t> expected_colors;
for (size_t i=0; i < component_count; i++)
{
if (i > 0)

View file

@ -22,7 +22,7 @@
int writestr(char *str)
{
write(1, str, strlen(str));
write_ignore(1, str, strlen(str));
return 0;
}

View file

@ -383,8 +383,6 @@ static void mark_process_status(const job_t *j, process_t *p, int status)
}
else
{
ssize_t ignore __attribute__((unused));
/* This should never be reached */
p->completed = 1;
@ -398,7 +396,7 @@ static void mark_process_status(const job_t *j, process_t *p, int status)
handler. If things aren't working properly, it's safer to
give up.
*/
ignore = write(2, mess, strlen(mess));
write_ignore(2, mess, strlen(mess));
}
}

View file

@ -364,7 +364,7 @@ void safe_perror(const char *message)
safe_append(buff, safe_strerror(err), sizeof buff);
safe_append(buff, "\n", sizeof buff);
write(STDERR_FILENO, buff, strlen(buff));
write_ignore(STDERR_FILENO, buff, strlen(buff));
errno = err;
}