Skip to contentSkip to conversation

perf tools:remove unneeded variable from perf_event_attr__fprintf()

PATCH In review [email protected] 3 participants 3 messages Jun 14, 2023 – Jan 3, 2024 1 message not in the archive perf events

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 perf tools:remove unneeded variable from perf_event_attr__fprintf()

fix the following coccicheck warning:

tools/perf/util/perf_event_attr_fprintf.c:97:5-8: Unneeded variable: "ret". Return "0".

---
 tools/perf/util/perf_event_attr_fprintf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/perf_event_attr_fprintf.c +1 -2
index 7e5e7b30510d..4a8f625b80c7 100644
@@ -94,7 +94,6 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
                  attr__fprintf_f attr__fprintf, void *priv)
 {
     char buf[BUF_SIZE];
-    int ret = 0;
 
     PRINT_ATTRf(type, p_unsigned);
     PRINT_ATTRf(size, p_unsigned);
@@ -155,5 +154,5 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
     PRINT_ATTRf(aux_sample_size, p_unsigned);
     PRINT_ATTRf(sig_data, p_unsigned);
 
-    return ret;
+    return 0;
 }
reviewer Acked-by on v1 1/1
#2 lore raw
Quoted 7 lines · On Tue, Jun 13, 2023 at 11:25 PM <[email protected]> wrote:

fix the following coccicheck warning:

tools/perf/util/perf_event_attr_fprintf.c:97:5-8: Unneeded variable:
"ret". Return "0".

Thanks,
Ian

Quoted 26 lines
---
  tools/perf/util/perf_event_attr_fprintf.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/perf_event_attr_fprintf.c +0 -1
index 7e5e7b30510d..4a8f625b80c7 100644
@@ -94,7 +94,6 @@ int perf_event_attr__fprintf(FILE *fp, struct
 perf_event_attr *attr,
                   attr__fprintf_f attr__fprintf, void *priv)
  {
      char buf[BUF_SIZE];
-    int ret = 0;
 
      PRINT_ATTRf(type, p_unsigned);
      PRINT_ATTRf(size, p_unsigned);
tools/perf/util/perf_event_attr_fprintf.c +1 -1
@@ -155,5 +154,5 @@ int perf_event_attr__fprintf(FILE *fp, struct
 perf_event_attr *attr,
      PRINT_ATTRf(aux_sample_size, p_unsigned);
      PRINT_ATTRf(sig_data, p_unsigned);
 
-    return ret;
+    return 0;
  }
#3 lore raw

Em Wed, Jul 12, 2023 at 06:20:12PM -0700, Ian Rogers escreveu:

Quoted 10 lines · On Tue, Jun 13, 2023 at 11:25 PM <[email protected]> wrote:
Quoted 7 lines

fix the following coccicheck warning:

tools/perf/util/perf_event_attr_fprintf.c:97:5-8: Unneeded variable:
"ret". Return "0".

util/perf_event_attr_fprintf.c: In function ‘perf_event_attr__fprintf’:
util/perf_event_attr_fprintf.c:256:17: error: ‘ret’ undeclared (first use in this function)

  256 |                 ret += attr__fprintf(fp, _n, buf, priv);\
      |                 ^~~
util/perf_event_attr_fprintf.c:267:9: note: in expansion of macro ‘PRINT_ATTRn’
  267 |         PRINT_ATTRn("type", type, p_type_id, true);
      |         ^~~~~~~~~~~

All those PRINT_ATTRf use that ret variable:

#define PRINT_ATTRn(_n, _f, _p, _a)                     \
do {                                                    \
        if (_a || attr->_f) {                           \
                _p(attr->_f);                           \
                ret += attr__fprintf(fp, _n, buf, priv);\
        }                                               \
} while (0)

#define PRINT_ATTRf(_f, _p) PRINT_ATTRn(#_f, _f, _p, false

- Arnaldo

Quoted 29 lines

Thanks,
Ian

Quoted 26 lines
---
  tools/perf/util/perf_event_attr_fprintf.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/perf_event_attr_fprintf.c +0 -1
index 7e5e7b30510d..4a8f625b80c7 100644
@@ -94,7 +94,6 @@ int perf_event_attr__fprintf(FILE *fp, struct
 perf_event_attr *attr,
                   attr__fprintf_f attr__fprintf, void *priv)
  {
      char buf[BUF_SIZE];
-    int ret = 0;
 
      PRINT_ATTRf(type, p_unsigned);
      PRINT_ATTRf(size, p_unsigned);
tools/perf/util/perf_event_attr_fprintf.c +1 -1
@@ -155,5 +154,5 @@ int perf_event_attr__fprintf(FILE *fp, struct
 perf_event_attr *attr,
      PRINT_ATTRf(aux_sample_size, p_unsigned);
      PRINT_ATTRf(sig_data, p_unsigned);
 
-    return ret;
+    return 0;
  }
Signature · 1 line
- Arnaldo