@@ -35,8 +35,14 @@ int main(void)
pwd = getpwnam("nobody");
if (pwd != NULL) {
- setgid(pwd->pw_gid);
- setuid(pwd->pw_uid);
+ if (setgid(pwd->pw_gid)) {
+ perror("setgid");
+ return PTS_UNRESOLVED;
+ }
+ if (setuid(pwd->pw_uid)) {
+ perror("setuid");
+ return PTS_UNRESOLVED;
+ }
}
}
@@ -157,7 +157,8 @@ int main(void)
if (ret != 0)
UNRESOLVED(errno, "Failed to close the message catalog");
- system("rm -f " MESSCAT_IN " " MESSCAT_OUT);
+ unlink(MESSCAT_IN);
+ unlink(MESSCAT_OUT);
#if VERBOSE > 0
output("Test passed\n");
@@ -55,7 +55,10 @@ int main(void)
*/
/* this is added incase user is root. If user is normal user, then it
* has no effect on the tests */
- setuid(1);
+ if (setuid(1)) {
+ perror("setuid");
+ return PTS_UNRESOLVED;
+ }
if (-1 == kill(1, 0)) {
if (EPERM == errno) {
@@ -23,7 +23,10 @@ int main(void)
{
/* this is added incase user is root. If user is normal user, then it
* has no effect on the tests */
- setuid(1);
+ if (setuid(1)) {
+ perror("setuid");
+ return PTS_UNRESOLVED;
+ }
if (kill(1, 0) != -1) {
printf
@@ -33,6 +33,9 @@
#include "posixtest.h"
#include "tempfile.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
static void sigbus_handler(int signum)
@@ -44,6 +47,8 @@ static void sigbus_handler(int signum)
}
}
+#pragma GCC diagnostic pop
+
int main(void)
{
#ifndef _POSIX_MEMORY_PROTECTION
@@ -31,6 +31,9 @@
#include <unistd.h>
#include "posixtest.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
static void sigbus_handler(int signum)
@@ -42,6 +45,8 @@ static void sigbus_handler(int signum)
}
}
+#pragma GCC diagnostic pop
+
int main(void)
{
#ifndef _POSIX_MEMORY_PROTECTION
@@ -131,7 +131,11 @@ int main(void)
printf("Got EAGAIN: %s\n", strerror(errno));
printf("Test PASSED\n");
/* Change user to root */
- seteuid(0);
+ if (seteuid(0)) {
+ close(fd);
+ perror("seteuid");
+ return PTS_UNRESOLVED;
+ }
close(fd);
munmap(pa, len);
return PTS_PASS;
@@ -61,10 +61,14 @@ int main(void)
printf(TNAME " Error at open(): %s\n", strerror(errno));
return PTS_UNRESOLVED;
}
- /* file is empty now, will cause "Bus error" */
- write(fd, fname, sizeof(int));
unlink(fname);
+ if (ftruncate(fd, sizeof(int))) {
+ perror("ftruncate");
+ close(fd);
+ return PTS_UNRESOLVED;
+ }
+
pa = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (pa == MAP_FAILED) {
printf(TNAME " Error at mmap: %s\n", strerror(errno));
@@ -10,8 +10,8 @@
*
* Steps:
* 1. Create a new thread that will go into a never-ending while loop.
- * 2. If the thread is truly asynchronise, then the main function will
- * continue instead of waiting for the thread to return (which in never
+ * 2. If the thread is truly asynchronous, then the main function will
+ * continue instead of waiting for the thread to return (which it never
* does in this test case).
* 3. An alarm is set to go off (i.e. send the SIGARLM signal) after 3
* seconds. This is done for 'timeing-out' reasons, in case main DOES
@@ -30,6 +30,8 @@
static void *a_thread_function();
static void alarm_handler();
+static volatile int alarm_triggered;
+
static pthread_t a;
int main(void)
@@ -72,6 +74,9 @@ static void *a_thread_function()
return NULL;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
/* If this handler is called, that means that the test has failed. */
@@ -80,3 +85,5 @@ static void alarm_handler()
WRITE("Test FAILED: Alarm fired while waiting for cancelation\n");
_exit(PTS_FAIL);
}
+
+#pragma GCC diagnostic pop
@@ -125,7 +125,10 @@ int main(void)
return PTS_UNRESOLVED;
}
- pipe(the_pipe);
+ if (pipe(the_pipe)) {
+ perror("pipe");
+ return PTS_UNRESOLVED;
+ }
for (i = 0; i < nb_child; i++) {
child_pid[i] = fork();
@@ -129,7 +129,10 @@ int main(void)
return PTS_UNRESOLVED;
}
- pipe(the_pipe);
+ if (pipe(the_pipe)) {
+ perror("pipe");
+ return PTS_UNRESOLVED;
+ }
for (i = 0; i < nb_child; i++) {
child_pid[i] = fork();
@@ -45,18 +45,21 @@ static int child_busy(int fd)
alarm(4);
/* Tell the parent we're ready */
- write(fd, "go", 2);
+ if (write(fd, "go", 2) == -1) {
+ perror("write");
+ exit(PTS_UNRESOLVED);
+ }
for (;;) {
rc = sched_yield();
if (rc) {
ERR_LOG("child: sched_yield", rc);
- exit(1);
+ exit(PTS_FAIL);
}
}
/* should not get here */
- exit(2);
+ exit(PTS_UNRESOLVED);
}
int main(void)
@@ -95,19 +95,22 @@ int main(void)
fd = shm_open(SHM_NAME, O_RDWR | O_TRUNC, 0);
if (fd == -1) {
perror("An error occurs when calling shm_open()");
- seteuid(getuid());
+ if (seteuid(getuid()))
+ perror("seteuid");
shm_unlink(SHM_NAME);
return PTS_UNRESOLVED;
}
if (fstat(fd, &stat_buf) != 0) {
perror("An error occurs when calling fstat()");
- seteuid(getuid());
+ if (seteuid(getuid()))
+ perror("seteuid");
shm_unlink(SHM_NAME);
return PTS_UNRESOLVED;
}
- seteuid(getuid());
+ if (seteuid(getuid()))
+ perror("seteuid");
shm_unlink(SHM_NAME);
if (stat_buf.st_uid == old_uid && stat_buf.st_gid == old_gid) {
@@ -86,7 +86,8 @@ int main(void)
return PTS_UNRESOLVED;
}
- seteuid(getuid());
+ if (seteuid(getuid()))
+ perror("seteuid");
if (fstat(fd, &stat_after) != 0) {
perror("An error occurs when calling fstat()");
@@ -69,12 +69,14 @@ int main(void)
result = shm_unlink(SHM_NAME);
if (result == -1 && errno == EACCES) {
printf("Test PASSED\n");
- seteuid(getuid());
+ if (seteuid(getuid()))
+ perror("seteuid");
shm_unlink(SHM_NAME);
return PTS_PASS;
} else if (result == -1) {
perror("Unexpected error");
- seteuid(getuid());
+ if (seteuid(getuid()))
+ perror("seteuid");
shm_unlink(SHM_NAME);
return PTS_FAIL;
}
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -39,10 +39,12 @@
#include <signal.h>
#include <errno.h>
#include "posixtest.h"
+static volatile sig_atomic_t called = 0;
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
-static volatile sig_atomic_t called = 0;
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
static void handler(int sig, siginfo_t *info, void *context)
{
@@ -57,6 +59,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -40,10 +40,13 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+
+#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
+
static void handler(int sig, siginfo_t *info, void *context)
{
(void) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context)
called = 1;
}
+#pragma GCC diagnostic pop
+
int main(void)
{
int ret;
@@ -59,7 +59,10 @@ int main(int argc, char *argv[])
/* Get abs path if needed and exec ourself */
if (*argv[0] != '/') {
- getcwd(path, PATH_MAX);
+ if (getcwd(path, PATH_MAX) == NULL) {
+ perror("getcwd");
+ exit(PTS_UNRESOLVED);
+ }
strcat(path, "/");
strcat(path, argv[0]);
} else {
@@ -46,7 +46,8 @@ static int get_online_cpu_from_sysfs(void)
f = fopen("/sys/devices/system/cpu/online", "r");
if (!f)
return -1;
- fscanf(f, "%d", &cpu);
+ if (!fscanf(f, "%d", &cpu))
+ cpu = -1;
fclose(f);
return cpu;