Skip to content

Commit

Permalink
Only provide warnings with -V
Browse files Browse the repository at this point in the history
  • Loading branch information
zyedidia committed Jan 24, 2025
1 parent d557482 commit c8b9c99
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 23 deletions.
1 change: 0 additions & 1 deletion liblfi/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ load(struct LFIAddrSpace* as, buf_t buf, uintptr_t base, uintptr_t* pfirst, uint
}

if (!elfcheck(&ehdr)) {
WARN("elfcheck failed");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion liblfi/host/posix/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ futexnew(struct TuxProc* proc, uintptr_t addr)
{
struct List* e;
if (!(e = list_first(proc->futexes.free))) {
WARN("ran out of futexes");
WARN(proc->tux, "ran out of futexes");
return NULL;
}
list_remove(&proc->futexes.free, e);
Expand Down
6 changes: 3 additions & 3 deletions liblfi/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <libelf.h>
#include <gelf.h>

int perf_output_jit_interface_file(uint8_t * buffer, size_t file_size, uintptr_t offset) {
int perf_output_jit_interface_file(uint8_t *buffer, size_t file_size, uintptr_t offset) {
Elf *e = elf_memory((char *) buffer, file_size);
if (!e) {
fprintf(stderr, "elf_memory failed: %s\n", elf_errmsg(-1));
Expand Down Expand Up @@ -89,9 +89,9 @@ int perf_output_jit_interface_file(uint8_t * buffer, size_t file_size, uintptr_t
#include <stdio.h>
#include "print.h"

int perf_output_jit_interface_file(uint8_t * buffer, size_t file_size, uintptr_t offset) {
int perf_output_jit_interface_file(uint8_t *buffer, size_t file_size, uintptr_t offset) {
(void) buffer, (void) file_size, (void) offset;
WARN("perf support is disabled because liblfi was built without libelf");
fprintf(stderr, "perf support is disabled because liblfi was built without libelf");
return 0;
}

Expand Down
7 changes: 4 additions & 3 deletions liblfi/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
fprintf(stderr, SGR_INFO "[liblfi] " fmt SGR_RESET "\n", ##__VA_ARGS__); \
} while (0)

#define WARN(fmt, ...) \
do { \
fprintf(stderr, SGR_WARN "[liblfi] WARN: " fmt SGR_RESET "\n", ##__VA_ARGS__); \
#define WARN(tux, fmt, ...) \
do { \
if (tux->opts.verbose) \
fprintf(stderr, SGR_WARN "[liblfi] WARN: " fmt SGR_RESET "\n", ##__VA_ARGS__); \
} while (0)

#define DBG(fmt, ...) \
Expand Down
4 changes: 2 additions & 2 deletions liblfi/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ procfile(struct TuxThread* p, uint8_t* prog, size_t progsz, int argc, char** arg
if (cwk_path_is_absolute(interppath)) {
interp = bufreadfile(p->proc->tux, interppath);
if (!interp.data) {
WARN("error opening dynamic linker %s: %s", interppath, strerror(errno));
WARN(p->proc->tux, "error opening dynamic linker %s: %s", interppath, strerror(errno));
free(interppath);
return false;
}
VERBOSE(p->proc->tux, "dynamic linker: %s", interppath);
} else {
WARN("interpreter ignored because it is relative path: %s", interppath);
WARN(p->proc->tux, "interpreter ignored because it is relative path: %s", interppath);
}
free(interppath);
}
Expand Down
1 change: 1 addition & 0 deletions liblfi/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ syshandle(struct TuxThread* p, uintptr_t sysno, uintptr_t a0, uintptr_t a1,
SYS(prctl, sys_prctl(proc, a0, a1, a2, a3, a4))
SYS(set_robust_list, 0)
SYS(membarrier, 0)
SYS(sigaltstack, 0)
SYS(statx, -TUX_ENOSYS)
SYS(rseq, -TUX_ENOSYS)
SYS(prlimit64, -TUX_ENOSYS)
Expand Down
2 changes: 1 addition & 1 deletion liblfi/syscalls/sys_fcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ int
sys_fcntl(struct TuxProc* p, int fd, int cmd, uintptr_t va0, uintptr_t va1,
uintptr_t va2, uintptr_t va3)
{
WARN("fcntl ignored");
WARN(p->tux, "fcntl ignored");
return 0;
}
3 changes: 1 addition & 2 deletions liblfi/syscalls/sys_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ sys_fstat(struct TuxProc* p, int fd, lfiptr_t statbufp)
return sys_newfstatat(p, fd, 0, statbufp, TUX_AT_EMPTY_PATH);
}


int
sys_stat(struct TuxProc* p, lfiptr_t pathp, lfiptr_t statbufp)
{
Expand Down Expand Up @@ -380,7 +379,7 @@ sys_faccessat2(struct TuxProc* p, int dirfd, uintptr_t pathp, int mode, int flag
if (dirfd != TUX_AT_FDCWD && !dir)
return -TUX_EBADF;
if (flags != 0) {
WARN("faccessat2 used with non-zero flags");
WARN(p->tux, "faccessat2 used with non-zero flags");
return -TUX_EINVAL;
}
const char* path = procpath(p, pathp);
Expand Down
2 changes: 1 addition & 1 deletion liblfi/syscalls/sys_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ sys_sysinfo(struct TuxProc* p, lfiptr_t infop)
int
sys_getrlimit(struct TuxProc* p, int resource, uintptr_t rlimp)
{
WARN("getrlimit ignored");
WARN(p->tux, "getrlimit ignored");
return 0;
}
2 changes: 1 addition & 1 deletion liblfi/syscalls/sys_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sys_ioctl(struct TuxProc* p, int fd, unsigned long request, uintptr_t va0,
if (fd != 0 && fd != 1 && fd != 2)
return -TUX_EINVAL;
if (request != TUX_TIOCGWINSZ) {
WARN("unknown ioctl request: %ld", request);
WARN(p->tux, "unknown ioctl request: %ld", request);
return -TUX_EINVAL;
}
uint8_t* wsb = procbufalign(p, va0, sizeof(struct WinSize), alignof(struct WinSize));
Expand Down
2 changes: 1 addition & 1 deletion liblfi/syscalls/sys_prctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sys_prctl(struct TuxProc* p, int op, uint64_t arg2, uint64_t arg3, uint64_t arg4
case TUX_PR_SET_NAME:
return pr_set_name(p, arg2);
default:
WARN("unknown prctl op %d", op);
WARN(p->tux, "unknown prctl op %d", op);
return -TUX_EINVAL;
}
}
4 changes: 2 additions & 2 deletions liblfi/syscalls/sys_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
int
sys_rt_sigaction(struct TuxProc* p, int sig, int64_t act, int64_t old, uint64_t sigsetsize)
{
WARN("unimplemented: rt_sigaction");
WARN(p->tux, "unimplemented: rt_sigaction");
return 0;
}

int
sys_rt_sigprocmask(struct TuxProc* p, int how, int64_t setaddr, int64_t oldsetaddr, uint64_t sigsetsize)
{
WARN("unimplemented: rt_sigprocmask");
WARN(p->tux, "unimplemented: rt_sigprocmask");
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions liblfi/syscalls/sys_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ sys_futex(struct TuxThread* p, lfiptr_t uaddrp, int op, uint32_t val,
case TUX_FUTEX_REQUEUE:
return futexrequeue(p, uaddr, op, val);
default:
WARN("invalid futex op %d\n", op);
WARN(p->proc->tux, "invalid futex op %d\n", op);
return -TUX_EINVAL;
}
}
Expand All @@ -79,7 +79,7 @@ static int
spawn(struct TuxThread* p, uint64_t flags, uint64_t stack, uint64_t ptidp, uint64_t ctidp, uint64_t tls, uint64_t func)
{
if ((flags & 0xff) != 0 && (flags & 0xff) != TUX_SIGCHLD) {
WARN("unsupported clone signal: %x", (unsigned) flags & 0xff);
WARN(p->proc->tux, "unsupported clone signal: %x", (unsigned) flags & 0xff);
return -TUX_EINVAL;
}
flags &= ~0xff;
Expand All @@ -92,11 +92,11 @@ spawn(struct TuxThread* p, uint64_t flags, uint64_t stack, uint64_t ptidp, uint6
flags &= ~ignored;

if (flags & ~allowed) {
WARN("disallowed clone flags: %lx", (unsigned long) (flags & ~allowed));
WARN(p->proc->tux, "disallowed clone flags: %lx", (unsigned long) (flags & ~allowed));
return -TUX_EINVAL;
}
if ((flags & required) != required) {
WARN("missing required clone flags: %lx", (unsigned long) required);
WARN(p->proc->tux, "missing required clone flags: %lx", (unsigned long) required);
return -TUX_EINVAL;
}

Expand Down Expand Up @@ -172,7 +172,7 @@ sys_sched_getaffinity(struct TuxProc* p, int32_t pid, uint64_t cpusetsize, int64
int
sys_sched_setaffinity(struct TuxProc* p, int32_t pid, uint64_t cpusetsize, int64_t maskaddr)
{
WARN("unimplemented: sched_setaffinity");
WARN(p->tux, "unimplemented: sched_setaffinity");
return 0;
}

Expand Down

0 comments on commit c8b9c99

Please sign in to comment.