Skip to contentSkip to conversation

perf jit: add missing curly braces

PATCH In review Dan Carpenter 4 participants 5 messages Jul 15, 2016 – Jul 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 perf jit: add missing curly braces

It doesn't change the runtime behavior, but my static checker complains that curly braces were intended.

tools/perf/jvmti/jvmti_agent.c +2 -1
index 3573f31..91bf333 100644
@@ -491,10 +491,11 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
 		if (sret != 1)
 			goto error;
 	}
-	if (padding_count)
+	if (padding_count) {
 		sret = fwrite_unlocked(pad_bytes, padding_count, 1, fp);
 		if (sret != 1)
 			goto error;
+	}
 
 	funlockfile(fp);
 	return 0;
#1 lore raw

Em Sat, Jul 16, 2016 at 12:07:12AM +0300, Dan Carpenter escreveu:

Quoted 2 lines

It doesn't change the runtime behavior, but my static checker complains that curly braces were intended.

Agreed, applying, thanks!

- Arnaldo

Quoted 19 lines
tools/perf/jvmti/jvmti_agent.c +2 -1
index 3573f31..91bf333 100644
@@ -491,10 +491,11 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
 		if (sret != 1)
 			goto error;
 	}
-	if (padding_count)
+	if (padding_count) {
 		sret = fwrite_unlocked(pad_bytes, padding_count, 1, fp);
 		if (sret != 1)
 			goto error;
+	}
 
 	funlockfile(fp);
 	return 0;
#2 lore raw

Em Fri, Jul 15, 2016 at 07:25:56PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 5 lines

Em Sat, Jul 16, 2016 at 12:07:12AM +0300, Dan Carpenter escreveu:

Quoted 2 lines

It doesn't change the runtime behavior, but my static checker complains that curly braces were intended.

Agreed, applying, thanks!

After fixing this:

[acme@jouet linux]$ am /wb/1.patch
Applying: perf jit: add missing curly braces
fatal: patch with only garbage at line 3
Patch failed at 0001 perf jit: add missing curly braces

Quoted 21 lines

- Arnaldo

Quoted 19 lines
tools/perf/jvmti/jvmti_agent.c +2 -1
index 3573f31..91bf333 100644
@@ -491,10 +491,11 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
 		if (sret != 1)
 			goto error;
 	}
-	if (padding_count)
+	if (padding_count) {
 		sret = fwrite_unlocked(pad_bytes, padding_count, 1, fp);
 		if (sret != 1)
 			goto error;
+	}
 
 	funlockfile(fp);
 	return 0;
#3 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

It doesn't change the runtime behavior, but my static checker complains that curly braces were intended.

This was clearly a bug. It did not fire when padding=0 because you never come out of the loop with sret != 0.
If padding=0, then you execute the fwrite() and then the sret test is just after, so this was working but I agree
this was not the intended code flow.
Thanks for tracking this down.

Quoted 17 lines
tools/perf/jvmti/jvmti_agent.c +2 -1
index 3573f31..91bf333 100644
@@ -491,10 +491,11 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
                if (sret != 1)
                        goto error;
        }
-       if (padding_count)
+       if (padding_count) {
                sret = fwrite_unlocked(pad_bytes, padding_count, 1, fp);
                if (sret != 1)
                        goto error;
+       }
 
        funlockfile(fp);
        return 0;
#4 lore raw

[tip:perf/core] perf jit: Add missing curly braces

In reply to Dan Carpenter
perf jit: Add missing curly braces
Commit-ID:  e03141db361399619f9ee97e00d4c6fe2b472104
Gitweb:     http://git.kernel.org/tip/e03141db361399619f9ee97e00d4c6fe2b472104
Author:     Dan Carpenter <[email protected]>
AuthorDate: Sat, 16 Jul 2016 00:07:12 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 18 Jul 2016 12:20:00 -0300

perf jit: Add missing curly braces

It doesn't change the runtime behavior, but my static checker complains that curly braces were intended.

---
 tools/perf/jvmti/jvmti_agent.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/jvmti/jvmti_agent.c +2 -1
index 3573f31..91bf333 100644
@@ -491,10 +491,11 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
 		if (sret != 1)
 			goto error;
 	}
-	if (padding_count)
+	if (padding_count) {
 		sret = fwrite_unlocked(pad_bytes, padding_count, 1, fp);
 		if (sret != 1)
 			goto error;
+	}
 
 	funlockfile(fp);
 	return 0;