]> granicus.if.org Git - strace/commitdiff
Move is_negated_errno() to new header negated_errno.h
authorLazar Trsic <Lazar.Trsic@imgtec.com>
Fri, 14 Jul 2017 09:31:03 +0000 (11:31 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 14 Jul 2017 23:55:23 +0000 (23:55 +0000)
Move is_negated_errno() to a separate new header file negated_errno.h
and include it just for architectures which require it.

is_negated_errno() is not used on those architectures
that have a dedicated register to signal a syscall error.

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.

* syscall.c (is_negated_errno): Move to ...
* negated_errno.h: ... new file.
* Makefile.am (strace_SOURCES): Add it.
* linux/aarch64/get_error.c: Include it.
* linux/arc/get_error.c: Likewise.
* linux/arm/get_error.c: Likewise.
* linux/avr32/get_error.c: Likewise.
* linux/bfin/get_error.c: Likewise.
* linux/crisv10/get_error.c: Likewise.
* linux/hppa/get_error.c: Likewise.
* linux/i386/get_error.c: Likewise.
* linux/ia64/get_error.c: Likewise.
* linux/m68k/get_error.c: Likewise.
* linux/metag/get_error.c: Likewise.
* linux/microblaze/get_error.c: Likewise.
* linux/or1k/get_error.c: Likewise.
* linux/riscv/get_error.c: Likewise.
* linux/s390/get_error.c: Likewise.
* linux/sh/get_error.c: Likewise.
* linux/sh64/get_error.c: Likewise.
* linux/tile/get_error.c: Likewise.
* linux/x86_64/get_error.c: Likewise.
* linux/xtensa/get_error.c: Likewise.

23 files changed:
Makefile.am
linux/aarch64/get_error.c
linux/arc/get_error.c
linux/arm/get_error.c
linux/avr32/get_error.c
linux/bfin/get_error.c
linux/crisv10/get_error.c
linux/hppa/get_error.c
linux/i386/get_error.c
linux/ia64/get_error.c
linux/m68k/get_error.c
linux/metag/get_error.c
linux/microblaze/get_error.c
linux/or1k/get_error.c
linux/riscv/get_error.c
linux/s390/get_error.c
linux/sh/get_error.c
linux/sh64/get_error.c
linux/tile/get_error.c
linux/x86_64/get_error.c
linux/xtensa/get_error.c
negated_errno.h [new file with mode: 0644]
syscall.c

index 05c2475ad4a586837c05ad366a747bef0e30190b..2517c0d467f97bcbb0f1179c8e0049c82ca2a32e 100644 (file)
@@ -179,6 +179,7 @@ strace_SOURCES =    \
        msghdr.h        \
        mtd.c           \
        native_defs.h   \
+       negated_errno.h \
        net.c           \
        netlink.c       \
        netlink.h       \
index a3aa12727c9c1758069d612fb237599725019393..b3287a0deabd8c0dbd4e8bbbad6affdcfc139c79 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 #define get_error arm_get_error
 #include "arm/get_error.c"
 #undef get_error
index e19debc10e86eada2a749ddcb4dd823195b788a0..39b5d1c0023d2a56498a1375872bb74703ad329e 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index fa81dd76fb0606ccf520d480aa07410dca80b18b..02d7e65de953d8cfc26ba4a43aa5b204724a0d3b 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 75e7f67f6364f116c37c2c915bdae06bb5c1a0d0..b53c8f6c61962f682b2b97eb1a10d1c552439138 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 80aeb377f788b4fc99df9750a8a36a226946a987..76e4099ddd1ee39cfd2a17e2de985514b82aaedb 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index b9da923f8b7a80dc4e605283db0486bc37b68edd..2c81f1b7fdeb34cbb7afe75e3c68aea2a3620d57 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index a2a7c0ea662b2df49bd622432d08bce871251fc2..8b23f3056c97854db4643a48a347c45c85ca4abb 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 1f63605e107f9b66c32a1c31dc35b9dce15aeaab..9e0be03efc3dcc3960e56ce038319eb67ea96507 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 52daa7f44d448ee66607b5fe45d473a641b7184d..41cae92e708cdc44b46fdedfe4945630a180cff0 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 3ad51a08d3a4ead700c53288ee2be4aa3a09bf89..edd69cfcc7b6feb705b93d3220bb720f09b8daf1 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index b7d287f9a09f6c781ac8790867469b0c3b38f384..5415b39b2b9cb095d3d34b98bd11ad36fc92303b 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 878e24f67e2a23b47ffc45a1e4ff923f67b13573..1da69c0e722fbf287b8ff536f0d3b89ae3cba5a9 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 40e00bf4652e9ee0542c4e1306a989011d1bea8c..f6a327132422138817e83c31062cd8a481f3484b 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index be640d0abb92cc4ea477e7e64f0258686b9ca71f..2b2594fc8d0f15fffcd8d9a10655bcac2782b741 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index f491962de8cc92907b8b3f261f430cebe0c64518..6d4d0a5e501f7ec04ee05e813d9747fec36da44e 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 158ff9e6ce48f9b15d83d92cf63704a6dd64aeed..0bb6fc50af2c59c9f1264ea661a748a5d1cac672 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 7858df7c2697fd197d1ed741509c22908cb8737b..0a9001d8abd8291a39e1fcf684729dcb059fa79d 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 9949af4f24a5fd7f27b5f8b667055ecf838e5aeb..1f007bad8c8aec3eb2a56559eaa6295d0303e145 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 9411625b9948220e5be7a0626048eaa44fd14bf1..440fdc74a0a9a0a7b0807725884687f5333fc0d0 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
index 51ccd3b84cdaa837a198d6ce86aa602cfdc48b4c..f49cc46784a21f125112ecc4670de8db0b8c6559 100644 (file)
@@ -1,3 +1,5 @@
+#include "negated_errno.h"
+
 static void
 get_error(struct tcb *tcp, const bool check_errno)
 {
diff --git a/negated_errno.h b/negated_errno.h
new file mode 100644 (file)
index 0000000..9ec851b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015-2017 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef STRACE_NEGATED_ERRNO_H
+#define STRACE_NEGATED_ERRNO_H
+
+/*
+ * Check the syscall return value register value for whether it is
+ * a negated errno code indicating an error, or a success return value.
+ */
+static inline bool
+is_negated_errno(kernel_ulong_t val)
+{
+       /* Linux kernel defines MAX_ERRNO to 4095. */
+       kernel_ulong_t max = -(kernel_long_t) 4095;
+
+#ifndef current_klongsize
+       if (current_klongsize < sizeof(val)) {
+               val = (uint32_t) val;
+               max = (uint32_t) max;
+       }
+#endif /* !current_klongsize */
+
+       return val >= max;
+}
+
+#endif /* !STRACE_NEGATED_ERRNO_H */
index 02626c73e8fd6ec1185d4dacf4f0fb61af42b6e3..f21a1467fee3211f43b328d79c2c228c0e1019d8 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1047,26 +1047,6 @@ restore_cleared_syserror(struct tcb *tcp)
        tcp->u_error = saved_u_error;
 }
 
-/*
- * Check the syscall return value register value for whether it is
- * a negated errno code indicating an error, or a success return value.
- */
-static inline bool
-is_negated_errno(kernel_ulong_t val)
-{
-       /* Linux kernel defines MAX_ERRNO to 4095. */
-       kernel_ulong_t max = -(kernel_long_t) 4095;
-
-#ifndef current_klongsize
-       if (current_klongsize < sizeof(val)) {
-               val = (uint32_t) val;
-               max = (uint32_t) max;
-       }
-#endif /* !current_klongsize */
-
-       return val >= max;
-}
-
 #include "arch_regs.c"
 
 #ifdef HAVE_GETRVAL2