From 041b3ee42e7c6338f482320bcc649aff254ae892 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 18 Aug 2011 12:48:56 +0200 Subject: [PATCH] Cosmetic fixes, no code changes * defs.h: Add/reformat comments. * signal.c: Remove wrong comment. Add warning directive when we detect that NSIG is undefined. Add comment about NSIG on ARM. Fix typo in comment. (signame): Reformat code a bit without changes to logic. Shorten static buffer. (sys_rt_sigprocmask): Remove stray empty line. * syscall.c: Add warning directive when we detect that NSIG is undefined. Add comment about NSIG on ARM. Signed-off-by: Denys Vlasenko --- defs.h | 5 +++-- signal.c | 25 ++++++++++++++----------- syscall.c | 2 ++ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/defs.h b/defs.h index aaa290e0..02242afc 100644 --- a/defs.h +++ b/defs.h @@ -57,8 +57,8 @@ #endif #endif #ifndef DEFAULT_STRLEN -#define DEFAULT_STRLEN 32 /* default maximum # of bytes printed in - `printstr', change with `-s' switch */ +/* default maximum # of bytes printed in `printstr', change with -s switch */ +#define DEFAULT_STRLEN 32 #endif #ifndef DEFAULT_ACOLUMN #define DEFAULT_ACOLUMN 40 /* default alignment column for results */ @@ -67,6 +67,7 @@ # ifdef HPPA # define MAX_ARGS 6 /* maximum number of args to a syscall */ # else +/* Way too big. Switch your arch to saner size after you tested that it works */ # define MAX_ARGS 32 /* maximum number of args to a syscall */ # endif #endif diff --git a/signal.c b/signal.c index c7c9a6a6..889134ad 100644 --- a/signal.c +++ b/signal.c @@ -70,7 +70,7 @@ #ifdef IA64 # include -#endif /* !IA64 */ +#endif #if defined (LINUX) && defined (SPARC64) # undef PTRACE_GETREGS @@ -131,13 +131,17 @@ struct sigcontext #endif /* M68K */ #endif /* !I386 */ #endif /* !HAVE_ASM_SIGCONTEXT_H */ + #ifndef NSIG +#warning: NSIG is not defined, using 32 #define NSIG 32 #endif #ifdef ARM +/* Ugh. Is this really correct? ARM has no RT signals?! */ #undef NSIG #define NSIG 32 #endif + #endif /* LINUX */ const char *const signalent0[] = { @@ -178,7 +182,7 @@ static const struct xlat sigvec_flags[] = { #if defined LINUX && (defined I386 || defined X86_64) /* The libc headers do not define this constant since it should only be - used by the implementation. So wwe define it here. */ + used by the implementation. So we define it here. */ # ifndef SA_RESTORER # define SA_RESTORER 0x04000000 # endif @@ -261,18 +265,18 @@ static const struct xlat sigprocmaskcmds[] = { const char * signame(int sig) { - static char buf[30]; - if (sig >= 0 && sig < nsignals) { + static char buf[sizeof("SIGRT_%d") + sizeof(int)*3]; + + if (sig >= 0 && sig < nsignals) return signalent[sig]; #ifdef SIGRTMIN - } else if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) { - sprintf(buf, "SIGRT_%ld", (long)(sig - __SIGRTMIN)); - return buf; -#endif /* SIGRTMIN */ - } else { - sprintf(buf, "%d", sig); + if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) { + sprintf(buf, "SIGRT_%d", (int)(sig - __SIGRTMIN)); return buf; } +#endif + sprintf(buf, "%d", sig); + return buf; } #ifndef UNIXWARE @@ -1727,7 +1731,6 @@ sys_rt_sigprocmask(struct tcb *tcp) } else { if (!tcp->u_arg[2]) - tprintf("NULL"); else if (syserror(tcp)) tprintf("%#lx", tcp->u_arg[2]); diff --git a/syscall.c b/syscall.c index 99600f7a..2fd5bb49 100644 --- a/syscall.c +++ b/syscall.c @@ -90,9 +90,11 @@ #define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ #endif #ifndef NSIG +#warning: NSIG is not defined, using 32 #define NSIG 32 #endif #ifdef ARM +/* Ugh. Is this really correct? ARM has no RT signals?! */ #undef NSIG #define NSIG 32 #undef NR_SYSCALL_BASE -- 2.40.0