]> granicus.if.org Git - strace/commitdiff
Move is_filled and IS_ZERO to macros.h, rename IS_ZERO to IS_ARRAY_ZERO
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 21 Feb 2018 23:21:35 +0000 (00:21 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Mar 2018 20:44:34 +0000 (20:44 +0000)
* s390.c: Replace all IS_ZERO invocations with IS_ARRAY_ZERO.
(is_filled, IS_ZERO): Move...
* macros.h: ...here.
(is_filled): Add inline qualifier, add const qualifier to ptr.
(IS_ZERO): Rename to IS_ARRAY_ZERO, cast arr_ to "const char *".

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
macros.h
s390.c

index 222a852d71a29a3a81c0ca5a7fb26802a53e9026..b0b7a117da663eddafa9a94ee511c2900fe20e22 100644 (file)
--- a/macros.h
+++ b/macros.h
@@ -28,6 +28,9 @@
 #ifndef STRACE_MACROS_H
 #define STRACE_MACROS_H
 
+#include <stdbool.h>
+#include <sys/types.h>
+
 #include "gcc_compat.h"
 
 #define ARRAY_SIZE(a_) (sizeof(a_) / sizeof((a_)[0]) + MUST_BE_ARRAY(a_))
        (offsetof(type_, member_) + sizeof(((type_ *)0)->member_))
 #endif
 
+static inline bool
+is_filled(const char *ptr, char fill, size_t size)
+{
+       while (size--)
+               if (*ptr++ != fill)
+                       return false;
+
+       return true;
+}
+
+#define IS_ARRAY_ZERO(arr_)    \
+       is_filled((const char *) (arr_), 0, sizeof(arr_) + MUST_BE_ARRAY(arr_))
+
 #endif /* !STRACE_MACROS_H */
diff --git a/s390.c b/s390.c
index a9349936ac7794e1211ef20345453b8c5b14364f..222fd01f4b99b72ae32fc9c2d185e9ae627dfec8 100644 (file)
--- a/s390.c
+++ b/s390.c
@@ -451,18 +451,6 @@ decode_ebcdic(const char *ebcdic, char *ascii, size_t size)
        } while (0)
 
 
-static bool
-is_filled(char *ptr, char fill, size_t size)
-{
-       while (size--)
-               if (*ptr++ != fill)
-                       return false;
-
-       return true;
-}
-
-#define IS_ZERO(arr_) \
-       is_filled(arr_, '\0', sizeof(arr_) + MUST_BE_ARRAY(arr_))
 #define IS_BLANK(arr_) /* 0x40 is space in EBCDIC */ \
        is_filled(arr_, '\x40', sizeof(arr_) + MUST_BE_ARRAY(arr_))
 
@@ -541,13 +529,13 @@ print_sthyi_machine(struct tcb *tcp, struct sthyi_machine *hdr, uint16_t size,
                if (name_val || hdr->infmname)
                        PRINT_FIELD_EBCDIC(", ", *hdr, infmname);
 
-               if (id_val || !IS_ZERO(hdr->infmtype))
+               if (id_val || !IS_ARRAY_ZERO(hdr->infmtype))
                        PRINT_FIELD_EBCDIC(", ", *hdr, infmtype);
-               if (id_val || !IS_ZERO(hdr->infmmanu))
+               if (id_val || !IS_ARRAY_ZERO(hdr->infmmanu))
                        PRINT_FIELD_EBCDIC(", ", *hdr, infmmanu);
-               if (id_val || !IS_ZERO(hdr->infmseq))
+               if (id_val || !IS_ARRAY_ZERO(hdr->infmseq))
                        PRINT_FIELD_EBCDIC(", ", *hdr, infmseq);
-               if (id_val || !IS_ZERO(hdr->infmpman))
+               if (id_val || !IS_ARRAY_ZERO(hdr->infmpman))
                        PRINT_FIELD_EBCDIC(", ", *hdr, infmpman);
 
                PRINT_UNKNOWN_TAIL(hdr, size);
@@ -615,10 +603,10 @@ print_sthyi_partition(struct tcb *tcp, struct sthyi_partition *hdr,
        if (cnt_val || hdr->infpdifl)
                PRINT_FIELD_U(", ", *hdr, infpdifl);
 
-       if (!abbrev(tcp) && !IS_ZERO(hdr->reserved_1__))
+       if (!abbrev(tcp) && !IS_ARRAY_ZERO(hdr->reserved_1__))
                PRINT_FIELD_HEX_ARRAY(", ", *hdr, reserved_1__);
 
-       if (id_val || !IS_ZERO(hdr->infppnam))
+       if (id_val || !IS_ARRAY_ZERO(hdr->infppnam))
                PRINT_FIELD_EBCDIC(", ", *hdr, infppnam);
 
        if (!abbrev(tcp)) {
@@ -631,7 +619,7 @@ print_sthyi_partition(struct tcb *tcp, struct sthyi_partition *hdr,
                if (acap_val || hdr->infpabif)
                        PRINT_FIELD_WEIGHT(", ", *hdr, infpabif);
 
-               if (!IS_ZERO(hdr->infplgnm)) {
+               if (!IS_ARRAY_ZERO(hdr->infplgnm)) {
                        PRINT_FIELD_EBCDIC(", ", *hdr, infplgnm);
 
                        PRINT_FIELD_WEIGHT(", ", *hdr, infplgcp);
@@ -693,7 +681,7 @@ print_sthyi_hypervisor(struct tcb *tcp, struct sthyi_hypervisor *hdr,
                        tprints_comment("unknown hypervisor type");
                }
 
-               if (!IS_ZERO(hdr->reserved_1__))
+               if (!IS_ARRAY_ZERO(hdr->reserved_1__))
                        PRINT_FIELD_HEX_ARRAY(", ", *hdr, reserved_1__);
 
                if (mt || hdr->infycpt)
@@ -792,7 +780,7 @@ print_sthyi_guest(struct tcb *tcp, struct sthyi_guest *hdr, uint16_t size,
                        tprints_comment("unknown");
                }
 
-               if (!IS_ZERO(hdr->reserved_1__))
+               if (!IS_ARRAY_ZERO(hdr->reserved_1__))
                        PRINT_FIELD_HEX_ARRAY(", ", *hdr, reserved_1__);
        }
 
@@ -817,7 +805,7 @@ print_sthyi_guest(struct tcb *tcp, struct sthyi_guest *hdr, uint16_t size,
                        tprints_comment("unknown");
                }
 
-               if (!IS_ZERO(hdr->reserved_2__))
+               if (!IS_ARRAY_ZERO(hdr->reserved_2__))
                        PRINT_FIELD_HEX_ARRAY(", ", *hdr, reserved_2__);
        }
 
@@ -855,7 +843,7 @@ print_sthyi_guest(struct tcb *tcp, struct sthyi_guest *hdr, uint16_t size,
                        hdr->infgpflg & 0x07 ? " - ???" : "");
 
        if (!abbrev(tcp)) {
-               if (!IS_ZERO(hdr->reserved_3__))
+               if (!IS_ARRAY_ZERO(hdr->reserved_3__))
                        PRINT_FIELD_HEX_ARRAY(", ", *hdr, reserved_3__);
 
                if (!IS_BLANK(hdr->infgpnam))
@@ -946,7 +934,7 @@ print_sthyi_buf(struct tcb *tcp, kernel_ulong_t ptr)
        if (hdr->infhval2) /* Reserved */
                PRINT_FIELD_0X(", ", *hdr, infhval2);
 
-       if (!IS_ZERO(hdr->reserved_1__))
+       if (!IS_ARRAY_ZERO(hdr->reserved_1__))
                PRINT_FIELD_HEX_ARRAY(", ", *hdr, reserved_1__);
 
        PRINT_FIELD_U(", ", *hdr, infhygct);