[PATCH] Fix alignment bug in Safe-Linking
Carlos O'Donell
carlos@redhat.com
Mon Mar 30 20:57:36 GMT 2020
On 3/30/20 3:20 PM, Eyal Itkin wrote:
> OK, will do.
>
> I'm still not sure about how exactly I should fix the indentations. It
> looks like tabs equal 8 spaces, and no more than 7 spaces should be used in
> a single row. I did understand how spacing for braces and curly braces
> should work. In addition, I guess that when I split up long string to
> multiple lines I some how broken the indentations.
>
> I read the style guide but couldn't come up with anything on top of what I
> listed above. Is there something I'm missing? You listed at least one case
> that I should fix in which I simply can't see what's wrong.
Sorry, the hard part is that you can't just run indent on the whole file and
have it DTRT. This code is quite old, and we should fix that for you and future
developers submitting patches.
The best you can do is copy the entire #if USE_TCACHE block into a distinct C
file, the one from _int_free (line 4209-4245), stick a "if (1)" at the top to
keep the nested scope correctly indented, and then run indent on that.
You end up with this:
--- indent-orig.c 2020-03-30 16:52:07.698673512 -0400
+++ indent.c 2020-03-30 16:52:16.832397293 -0400
@@ -16,16 +16,17 @@
tcache_entry *tmp;
LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx);
for (tmp = tcache->entries[tc_idx];
- tmp;
- tmp = REVEAL_PTR (tmp->next))
- {
^^^ This line only has spaces, but needs a tab and several space.
- if (__glibc_unlikely (!aligned_OK (tmp)))
- malloc_printerr ("free(): unaligned chunk detected in tcache 2");
- if (tmp == e)
- malloc_printerr ("free(): double free detected in tcache 2");
- /* If we get here, it was a coincidence. We've wasted a
- few cycles, but don't abort. */
^^^ These need re-indenting given the new scope you added.
- }
^^^ Likewise similar with the first curly brace.
+ tmp; tmp = REVEAL_PTR (tmp->next))
+ {
+ if (__glibc_unlikely (!aligned_OK (tmp)))
+ malloc_printerr
+ ("free(): unaligned chunk detected in tcache 2");
+ if (tmp == e)
+ malloc_printerr
+ ("free(): double free detected in tcache 2");
+ /* If we get here, it was a coincidence. We've wasted a
+ few cycles, but don't abort. */
+ }
^^^ All fixed.
}
if (tcache->counts[tc_idx] < mp_.tcache_count)
---
This is really esoteric.
Say the word and I'll fix this for you and you can focus on the 32-bit fix? :-)
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list