Hi Lazar, On Mon, Jul 10, 2017 at 04:20:28PM +0200, Lazar Trsic wrote: > On architectures that use negated errno semantics, > function is_negated_errno() is never being called.
Just the otherwise, is_negated_errno() is not used on those architectures that have a dedicated register to signal a syscall error and therefore don't follow the negated errno semantics. > Use ARCH_USE_NEGATED_ERRNO macro to guard this function from > compiling for architectures: alpha, mips, nios2, powerpc and sparc. > > The issue was raised when compiling with clang, which is more > strict regarding semantics of unused static inline functions > defined in C files and will issue a -Wunused-function warrning > if they are not used anywhere. > > * linux/alpha/arch_regs.h: Define ARCH_USE_NEGATED_ERRNO. > * linux/mips/arch_regs.h: Likewise. > * linux/nios2/arch_regs.h: Likewise. > * linux/powerpc/arch_regs.h: Likewise. > * linux/sparc/arch_regs.h: Likewise. > * syscall.c: Use ARCH_USE_NEGATED_ERRNO around is_negated_errno(). I'd prefer a bit different approach: move is_negated_errno to a separate header file, e.g. negated_errno.h, and include it in those get_error.c files that call is_negated_errno. > Change-Id: I00dd74c87b93eeb0de7b794b4542f160f9554e89 I don't think this belongs to the main repository. > --- > linux/alpha/arch_regs.h | 2 ++ > linux/mips/arch_regs.h | 3 +++ > linux/nios2/arch_regs.h | 2 ++ > linux/powerpc/arch_regs.h | 2 ++ > linux/sparc/arch_regs.h | 2 ++ > syscall.c | 2 ++ > 6 files changed, 13 insertions(+) > > diff --git a/linux/alpha/arch_regs.h b/linux/alpha/arch_regs.h > index 66277fd..06f1569 100644 > --- a/linux/alpha/arch_regs.h > +++ b/linux/alpha/arch_regs.h > @@ -3,3 +3,5 @@ > #define REG_A3 19 > #define REG_FP 30 > #define REG_PC 64 > + > +#define ARCH_USE_NEGATED_ERRNO > diff --git a/linux/mips/arch_regs.h b/linux/mips/arch_regs.h > index 6372bad..d4ae308 100644 > --- a/linux/mips/arch_regs.h > +++ b/linux/mips/arch_regs.h > @@ -1,3 +1,4 @@ > + > struct mips_regs { > uint64_t uregs[38]; > }; > @@ -16,3 +17,5 @@ extern struct mips_regs mips_regs; > #define mips_REG_A5 mips_regs.uregs[REG_A0 + 5] > #define mips_REG_SP mips_regs.uregs[29] > #define mips_REG_EPC mips_regs.uregs[34] > + > +#define ARCH_USE_NEGATED_ERRNO > diff --git a/linux/nios2/arch_regs.h b/linux/nios2/arch_regs.h > index c4230ed..5eaa035 100644 > --- a/linux/nios2/arch_regs.h > +++ b/linux/nios2/arch_regs.h > @@ -1 +1,3 @@ > extern unsigned int *const nios2_sp_ptr; > + > +#define ARCH_USE_NEGATED_ERRNO > diff --git a/linux/powerpc/arch_regs.h b/linux/powerpc/arch_regs.h > index 1296e83..256ff46 100644 > --- a/linux/powerpc/arch_regs.h > +++ b/linux/powerpc/arch_regs.h > @@ -1 +1,3 @@ > extern struct pt_regs ppc_regs; > + > +#define ARCH_USE_NEGATED_ERRNO > diff --git a/linux/sparc/arch_regs.h b/linux/sparc/arch_regs.h > index ac11a1d..db78e7d 100644 > --- a/linux/sparc/arch_regs.h > +++ b/linux/sparc/arch_regs.h > @@ -5,3 +5,5 @@ extern struct pt_regs sparc_regs; > #define U_REG_O0 7 > #define U_REG_O1 8 > #define U_REG_FP 13 > + > +#define ARCH_USE_NEGATED_ERRNO > diff --git a/syscall.c b/syscall.c > index 02626c7..f455f60 100644 > --- a/syscall.c > +++ b/syscall.c > @@ -1047,6 +1047,7 @@ restore_cleared_syserror(struct tcb *tcp) > tcp->u_error = saved_u_error; > } > > +#ifndef ARCH_USE_NEGATED_ERRNO > /* > * Check the syscall return value register value for whether it is > * a negated errno code indicating an error, or a success return value. > @@ -1066,6 +1067,7 @@ is_negated_errno(kernel_ulong_t val) > > return val >= max; > } > +#endif > > #include "arch_regs.c" -- ldv
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel