Enforce -Werror in tests.

This commit is contained in:
4lDO2
2023-11-12 11:45:15 +01:00
parent 48f7ca7fe0
commit c76a12347f
8 changed files with 32 additions and 49 deletions
+2 -2
View File
@@ -17,8 +17,8 @@ after_includes = """
void *arg; \
void *prev; \
} __relibc_internal_pthread_ll_entry = { \
.routine = (routine), \
.arg = (arg), \
.routine = (void (*)(void *))(routine), \
.arg = (void *)(arg), \
}; \
__relibc_internal_pthread_cleanup_push(&__relibc_internal_pthread_ll_entry);
+4 -4
View File
@@ -22,10 +22,10 @@ pub mod sys;
type SigSet = BitSet<[c_ulong; 1]>;
pub const SIG_DFL: usize = 0;
pub const SIG_IGN: usize = 1;
pub const SIG_ERR: isize = -1;
pub const SIG_HOLD: isize = 2;
pub(crate) const SIG_DFL: usize = 0;
pub(crate) const SIG_IGN: usize = 1;
pub(crate) const SIG_ERR: isize = -1;
pub(crate) const SIG_HOLD: isize = 2;
pub const SIG_BLOCK: c_int = 0;
pub const SIG_UNBLOCK: c_int = 1;
+1
View File
@@ -227,6 +227,7 @@ FLAGS=\
-fno-builtin \
-fno-stack-protector \
-Wall \
-Werror \
-pedantic \
-g \
-I .
+13 -23
View File
@@ -4,49 +4,39 @@
#include <string.h>
#include <grp.h>
bool test_getgrgid(gid_t gid) {
struct group* out = getgrgid(gid);
void test_getgrgid(gid_t gid) {
struct group *out = getgrgid(gid);
if (out == NULL) {
printf("Did not find a group %d", gid);
return false;
printf("Did not find a group %d\n", gid);
return;
}
printf("getgrgid\n");
char* start = out->gr_name;
int len = strlen(out->gr_name);
printf(" %d = %s, GID: %d\n", gid, out->gr_name, out->gr_gid);
return true;
}
bool test_getgrgid_r(gid_t gid) {
char* buf[100];
void test_getgrgid_r(gid_t gid) {
char buf[100];
struct group grp;
struct group* out = &grp;
struct group* tmp;
struct group *tmp;
int status = getgrgid_r(gid, out, buf, sizeof(buf), &tmp);
int status = getgrgid_r(gid, &grp, buf, sizeof(buf), &tmp);
if (out == NULL) {
printf("Did not find a group %d", gid);
return false;
if (tmp == NULL) {
const char *reason = status != 0 ? strerror(status) : "(not found)";
printf("Did not find a group %d: %s\n", gid, reason);
return;
}
printf("getgrgid_r\n");
char* start = grp.gr_name;
int len = strlen(grp.gr_name);
printf(" %d = %s, GID: %d\n", gid, grp.gr_name, grp.gr_gid);
return true;
}
int main(void) {
test_getgrgid(1050);
test_getgrgid_r(1050);
}
}
+9 -19
View File
@@ -4,49 +4,39 @@
#include <string.h>
#include <grp.h>
bool test_getgrnam(char* gr_name) {
void test_getgrnam(const char *gr_name) {
struct group* out = getgrnam(gr_name);
if (out == NULL) {
printf("Did not find a group '%s'", gr_name);
return false;
return;
}
printf("getgrnam\n");
char* start = out->gr_name;
int len = strlen(out->gr_name);
printf(" '%s' = %d\n", gr_name, out->gr_gid);
return true;
}
bool test_getgrnam_r(char* gr_name) {
char* buf[100];
void test_getgrnam_r(const char *gr_name) {
char buf[100];
struct group grp;
struct group* out = &grp;
struct group* tmp;
int status = getgrnam_r(gr_name, out, buf, sizeof(buf), &tmp);
int status = getgrnam_r(gr_name, &grp, buf, sizeof(buf), &out);
if (out == NULL) {
printf("Did not find a group '%s'", gr_name);
return false;
const char *reason = (status != 0) ? strerror(status) : "(not found)";
printf("Did not find a group %s: %s\n", gr_name, reason);
return;
}
printf("getgrnam_r\n");
char* start = grp.gr_name;
int len = strlen(grp.gr_name);
printf(" '%s' = %d\n", gr_name, out->gr_gid);
return true;
}
int main(void) {
test_getgrnam("lcake");
test_getgrnam_r("lcake");
}
}
+1
View File
@@ -34,6 +34,7 @@ void *routine(void *arg) {
puts("6");
pthread_cleanup_pop(true);
pthread_cleanup_pop(true);
return NULL;
}
int main(void) {
+1 -1
View File
@@ -85,7 +85,7 @@ int main(void) {
errno = 0;
struct passwd *entry = NULL;
for (int i = 1; entry = getpwent(); ++i) {
for (int i = 1; (entry = getpwent()); ++i) {
int backup = errno;
printf("--- getpwent #%d ---\n", i);
if (backup != 0) {
+1
View File
@@ -66,6 +66,7 @@ void test_null_args() {
free(lineptr); \
stream = NULL; \
errno = 0; \
(void)n; \
} while (0);
static size_t counter = 0;