]> granicus.if.org Git - strace/commitdiff
nlattr: add const qualifiers to auto variables and function arguments
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 28 Jun 2017 01:40:00 +0000 (01:40 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 30 Jun 2017 21:38:49 +0000 (21:38 +0000)
This change does not affect the code generated by the compiler,
the purpose of these "const" qualifiers is to highlight the intent.

* nlattr.c (decode_nlattr_with_data, decode_nla_str, decode_nla_strn,
decode_nla_##name): Add const qualifier to tcp, addr, and len arguments.

nlattr.c

index 3a3a0d79befa51a3593aa2dd577f631268b5630d..ef3d7622656e879699b8b1a7e7cd44669c5a0295 100644 (file)
--- a/nlattr.c
+++ b/nlattr.c
@@ -61,10 +61,10 @@ print_nlattr(const struct nlattr *const nla,
 }
 
 static void
-decode_nlattr_with_data(struct tcb *tcp,
+decode_nlattr_with_data(struct tcb *const tcp,
                        const struct nlattr *const nla,
-                       kernel_ulong_t addr,
-                       kernel_ulong_t len,
+                       const kernel_ulong_t addr,
+                       const kernel_ulong_t len,
                        const struct xlat *const table,
                        const char *const dflt,
                        const nla_decoder_t *const decoders,
@@ -144,8 +144,10 @@ decode_nlattr(struct tcb *const tcp,
 }
 
 bool
-decode_nla_str(struct tcb *tcp, kernel_ulong_t addr,
-              kernel_ulong_t len, const void *const opaque_data)
+decode_nla_str(struct tcb *const tcp,
+              const kernel_ulong_t addr,
+              const kernel_ulong_t len,
+              const void *const opaque_data)
 {
        printstr_ex(tcp, addr, len, QUOTE_0_TERMINATED);
 
@@ -153,26 +155,30 @@ decode_nla_str(struct tcb *tcp, kernel_ulong_t addr,
 }
 
 bool
-decode_nla_strn(struct tcb *tcp, kernel_ulong_t addr,
-               kernel_ulong_t len, const void *const opaque_data)
+decode_nla_strn(struct tcb *const tcp,
+               const kernel_ulong_t addr,
+               const kernel_ulong_t len,
+               const void *const opaque_data)
 {
        printstrn(tcp, addr, len);
 
        return true;
 }
 
-#define DECODE_NLA_INTEGER(name, type, fmt)                            \
-bool                                                                   \
-decode_nla_ ## name(struct tcb *tcp, kernel_ulong_t addr,              \
-                   kernel_ulong_t len, const void *const opaque_data)  \
-{                                                                      \
-       type num;                                                       \
-                                                                       \
-       if (len < sizeof(num))                                          \
-               return false;                                           \
-       if (!umove_or_printaddr(tcp, addr, &num))                       \
-               tprintf(fmt, num);                                      \
-       return true;                                                    \
+#define DECODE_NLA_INTEGER(name, type, fmt)            \
+bool                                                   \
+decode_nla_ ## name(struct tcb *const tcp,             \
+                   const kernel_ulong_t addr,          \
+                   const kernel_ulong_t len,           \
+                   const void *const opaque_data)      \
+{                                                      \
+       type num;                                       \
+                                                       \
+       if (len < sizeof(num))                          \
+               return false;                           \
+       if (!umove_or_printaddr(tcp, addr, &num))       \
+               tprintf(fmt, num);                      \
+       return true;                                    \
 }
 
 DECODE_NLA_INTEGER(u8, uint8_t, "%" PRIu8)