-Wall -Werror
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
default: luad luac
|
||||
|
||||
CFLAGS=-Wall -Werror
|
||||
luad: LOADLIBES=-llua
|
||||
|
||||
install:
|
||||
|
||||
@@ -19,16 +19,29 @@
|
||||
#include <poll.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
static int sigchild_fd = -1;
|
||||
|
||||
static void handle_sigchld(int num) {
|
||||
if(sigchild_fd >= 0) {
|
||||
write(sigchild_fd, "\n", 1);
|
||||
(void) !write(sigchild_fd, "\n", 1);
|
||||
}
|
||||
}
|
||||
|
||||
#define die(...) error(EXIT_FAILURE, errno, __VA_ARGS__)
|
||||
static void noreturn die(char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if(errno > 0) {
|
||||
fprintf(stderr, "luad: %s: ", strerror(errno));
|
||||
} else {
|
||||
fprintf(stderr, "luad: ");
|
||||
}
|
||||
vfprintf(stderr, fmt, ap);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int open_socket(char * pathname) {
|
||||
struct sockaddr_un addr;
|
||||
@@ -94,7 +107,7 @@ int * fds_from_msg(struct msghdr *msg, int * peer_fds) {
|
||||
}
|
||||
}
|
||||
|
||||
int start_lua_child(lua_State *L,
|
||||
void start_lua_child(lua_State *L,
|
||||
char * command_line, int command_line_length,
|
||||
int * fds) {
|
||||
char * word = command_line;
|
||||
@@ -125,8 +138,6 @@ int start_lua_child(lua_State *L,
|
||||
int status = luaL_dofile(L, pathname);
|
||||
if (status) {
|
||||
die("Lua error: %s", lua_tostring(L, -1));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +146,8 @@ pid_t fork_lua(lua_State *L,
|
||||
int * fds) {
|
||||
pid_t pid = fork();
|
||||
if(pid == 0) {
|
||||
exit(start_lua_child(L, command_line, command_line_length,
|
||||
fds));
|
||||
start_lua_child(L, command_line, command_line_length, fds);
|
||||
exit(0);
|
||||
} else if(pid > 0) {
|
||||
free(command_line);
|
||||
return pid;
|
||||
@@ -151,7 +162,6 @@ struct peer_entry {
|
||||
struct sockaddr_un addr;
|
||||
} peer_entries[500];
|
||||
|
||||
|
||||
bool register_peer(pid_t pid, struct sockaddr_un *addr, int addrlen) {
|
||||
if(addrlen > sizeof (struct sockaddr_un))
|
||||
return false;
|
||||
@@ -210,7 +220,7 @@ int main(int argc, char **argv)
|
||||
|
||||
int socket = open_socket(socket_path);
|
||||
struct sockaddr_un peer_addr;
|
||||
socklen_t peer_addr_len;
|
||||
|
||||
char buf[1025];
|
||||
struct iovec iov[1];
|
||||
iov[0].iov_base = buf;
|
||||
@@ -271,8 +281,10 @@ int main(int argc, char **argv)
|
||||
pid_t pid;
|
||||
int wstatus;
|
||||
|
||||
read(pollfds[1].fd, buf, sizeof buf);
|
||||
while((pid=waitpid(0, &wstatus, WNOHANG)) > 0) {
|
||||
if(read(pollfds[1].fd, buf, sizeof buf) < 0)
|
||||
continue;
|
||||
|
||||
while((pid = waitpid(0, &wstatus, WNOHANG)) > 0) {
|
||||
struct peer_entry *peer = find_peer(pid);
|
||||
if(peer) {
|
||||
uint32_t ret = 0;
|
||||
|
||||
Reference in New Issue
Block a user