@@ -231,7 +231,7 @@ static void extract_handle_and_acquire(int fd,
static int binder_parse(int fd, binder_uintptr_t ptr, binder_size_t size)
{
binder_uintptr_t end = ptr + size;
- uint32_t cmd;
+ uint32_t cmd = BR_DEAD_REPLY;
while (ptr < end) {
cmd = *(uint32_t *)ptr;
@@ -156,7 +156,7 @@ static void reply_with_handle(int fd, struct binder_transaction_data *txn_in)
static int binder_parse(int fd, binder_uintptr_t ptr, binder_size_t size)
{
binder_uintptr_t end = ptr + size;
- uint32_t cmd;
+ uint32_t cmd = BR_DEAD_REPLY;
while (ptr < end) {
cmd = *(uint32_t *)ptr;
@@ -76,14 +76,16 @@ static void request_service_provider_fd(int fd,
break;
#if HAVE_BPF
case BPF_MAP_FD:
- obj.fd = create_bpf_map();
- if (obj.fd < 0)
+ result = create_bpf_map();
+ if (result < 0)
exit(70);
+ obj.fd = result;
break;
case BPF_PROG_FD:
- obj.fd = create_bpf_prog();
- if (obj.fd < 0)
+ result = create_bpf_prog();
+ if (result < 0)
exit(71);
+ obj.fd = result;
break;
#else
case BPF_MAP_FD:
@@ -122,7 +124,7 @@ static void request_service_provider_fd(int fd,
static int binder_parse(int fd, binder_uintptr_t ptr, binder_size_t size)
{
binder_uintptr_t end = ptr + size;
- uint32_t cmd;
+ uint32_t cmd = BR_DEAD_REPLY;
while (ptr < end) {
cmd = *(uint32_t *)ptr;
@@ -20,7 +20,7 @@ int main(int argc, char *argv[])
enum {
MAP_FD = 1,
PROG_FD
- } bpf_fd_type;
+ } bpf_fd_type = -1;
while ((opt = getopt(argc, argv, "mpv")) != -1) {
switch (opt) {
@@ -89,8 +89,8 @@ usage(char *pname)
static void
update_map(char *mapping, char *map_file)
{
- int fd, j;
- size_t map_len; /* Length of 'mapping' */
+ int fd;
+ size_t j, map_len; /* Length of 'mapping' */
/* Replace commas in mapping string with newlines */
@@ -106,7 +106,7 @@ update_map(char *mapping, char *map_file)
exit(EXIT_FAILURE);
}
- if (write(fd, mapping, map_len) != map_len) {
+ if (write(fd, mapping, map_len) != (ssize_t)map_len) {
fprintf(stderr, "ERROR: write %s: %s\n", map_file,
strerror(errno));
exit(EXIT_FAILURE);
@@ -43,7 +43,7 @@ int main(int argc, char **argv)
perror("malloc");
exit(-1);
}
- clone_stack = page + pagesize;
+ clone_stack = (unsigned char *)page + pagesize;
rc = getcon(&context_tmp);
if (rc < 0) {
@@ -9,7 +9,7 @@
#include <stdlib.h>
char my_path[1024];
-#define CLEANUP_AND_EXIT do { unlink(my_path); exit(1); } while (0)
+#define CLEANUP_AND_EXIT do { unlink(my_path); _exit(1); } while (0)
void handler(int sig)
{
@@ -43,7 +43,6 @@ int main(int argc, char **argv)
}
sun.sun_family = AF_UNIX;
- sunlen = sizeof(struct sockaddr_un);
strcpy(sun.sun_path, argv[2]);
sunlen = strlen(sun.sun_path) + 1 + sizeof(short);
strcpy(my_path, sun.sun_path);
@@ -27,7 +27,7 @@ int main(int argc, char **argv)
{
int opt, result, save_err;
const char *newcon;
- char *context, *fs_con = NULL, *base_dir, *type;
+ char *context, *fs_con = NULL, *base_dir = NULL, *type = NULL;
char fs_mount[PATH_MAX];
bool verbose = false;
context_t con_t;
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
size_t len;
ssize_t num;
int opt, index = 0, i, result = 0;
- char *mount_info[2], *buf = NULL, *item, *tgt;
+ char *mount_info[2], *buf = NULL, *item, *tgt = NULL;
bool verbose = false;
while ((opt = getopt(argc, argv, "t:v")) != -1) {
@@ -12,6 +12,7 @@
#define IPPROTO_MPTCP 262
#endif
+__attribute__((noreturn))
void usage(char *progname)
{
fprintf(stderr, "usage: %s protocol port\n", progname);
@@ -15,6 +15,7 @@
#define IPPROTO_MPTCP 262
#endif
+__attribute__((noreturn))
void usage(char *progname)
{
fprintf(stderr, "usage: %s protocol port\n", progname);
@@ -66,7 +66,7 @@ int main(int argc, char **argv)
fprintf(stderr, "%s: out of memory\n", argv[0]);
exit(-1);
}
- childargv[1] = malloc(6);
+ childargv[1] = malloc(11);
if (!childargv[1]) {
fprintf(stderr, "%s: out of memory\n", argv[0]);
exit(-1);
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
r_msg.sadb_msg_type != w_msg.sadb_msg_type ||
r_msg.sadb_msg_satype != w_msg.sadb_msg_satype ||
r_msg.sadb_msg_seq != w_msg.sadb_msg_seq ||
- r_msg.sadb_msg_pid != getpid()) {
+ (pid_t)r_msg.sadb_msg_pid != getpid()) {
fprintf(stderr, "Failed to read correct sadb_msg data:\n");
fprintf(stderr, "\tSent - ver: %d type: %d sa_type: %d seq: %d pid: %d\n",
w_msg.sadb_msg_version, w_msg.sadb_msg_type,
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
}
fd = open(file_name, O_RDONLY);
- if (!fd) {
+ if (fd < 0) {
fprintf(stderr, "Failed to open %s: %s\n",
file_name, strerror(errno));
exit(-1);
@@ -67,7 +67,7 @@ int main(int argc, char **argv)
}
pid = wait(&status);
- if (WIFEXITED(status)) {
+ if (pid >= 0 && WIFEXITED(status)) {
if (WEXITSTATUS(status) && nobounded) {
printf("%s: Kernels < v3.18 do not support bounded transitions under NNP.\n",
argv[0]);
@@ -86,6 +86,10 @@ int main(int argc, char *argv[])
FILE *f;
f = fopen(argv[optind], "r"); // open file for reading
+ if (!f) {
+ perror("test_fanotify:bad listen file");
+ exit(1);
+ }
fgetc(f); // read char from file
fclose(f);
@@ -100,9 +104,9 @@ int main(int argc, char *argv[])
if (fds.revents & POLLIN) {
struct fanotify_event_metadata buff[200];
- size_t len = read(fd, (void *)&buff, sizeof(buff));
+ ssize_t len = read(fd, (void *)&buff, sizeof(buff));
if (len == -1) {
- perror("test_fanotify:can't open file");
+ perror("test_fanotify:can't read file");
exit(1);
} else {
listening = 0;
@@ -138,12 +138,14 @@ int main(int argc, char **argv)
newrlimp = &newrlim;
if (soft) {
newrlim.rlim_max = oldrlim.rlim_max;
+ newrlim.rlim_cur = oldrlim.rlim_cur;
if (newrlim.rlim_cur == RLIM_INFINITY)
newrlim.rlim_cur = 1024;
else
newrlim.rlim_cur = oldrlim.rlim_cur / 2;
} else {
newrlim.rlim_cur = oldrlim.rlim_cur;
+ newrlim.rlim_max = oldrlim.rlim_max;
if (newrlim.rlim_max == RLIM_INFINITY)
newrlim.rlim_max = 1024;
else
@@ -105,9 +105,9 @@ void print_addr_info(struct sockaddr *sin, char *text)
char *get_ip_option(int fd, bool ipv4, socklen_t *opt_len)
{
- int result, i;
+ int result;
unsigned char ip_options[1024];
- socklen_t len = sizeof(ip_options);
+ socklen_t i, len = sizeof(ip_options);
char *ip_optbuf;
if (ipv4)
@@ -11,6 +11,7 @@
#include <errno.h>
#include <selinux/selinux.h>
+__attribute__((noreturn))
void usage(char *progname)
{
fprintf(stderr,
@@ -16,6 +16,7 @@
#define SCM_SECURITY 0x03
#endif
+__attribute__((noreturn))
void usage(char *progname)
{
fprintf(stderr,
@@ -17,6 +17,7 @@
#define SCM_SECURITY 0x03
#endif
+__attribute__((noreturn))
void print_usage(char *progname)
{
fprintf(stderr,