Re: [RFC, PATCH 2/4] elf_core_dump(): Remove DUMP_WRITE macro

From: AmÃrico Wang
Date: Tue Dec 15 2009 - 03:29:26 EST


On Tue, Dec 15, 2009 at 10:41 AM, Daisuke HATAYAMA
<d.hatayama@xxxxxxxxxxxxxx> wrote:
> In DUMP_WRITE macro, some local variables and goto statement are used
> implicitly, which makes it confusing to understand how the dumping
> process behaves. So, clean up it by unfolding the macro body directly
> to the point where the original macro is used plus a bit of style
> change.
>
> Now that the previous patch replaced ELF_CORE_EXTRA_* macros in
> fs/binfmt_elf.c, there is no users for DUMP_WRITE macro in
> fs/binfmt_elf.c. Thus remove the definition of DUMP_WRITE macro.
>
> Signed-off-by: Daisuke HATAYAMA <d.hatayama@xxxxxxxxxxxxxx>


I assume you at least did a build test?

I like this patch:

Acked-by: WANG Cong <xiyou.wangcong@xxxxxxxxx>

> ---
> Âfs/binfmt_elf.c | Â 17 ++++++++++-------
> Â1 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> index 5f7be51..9666a8a 100644
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -1277,10 +1277,6 @@ static int writenote(struct memelfnote *men, struct file *file,
> Â}
> Â#undef DUMP_WRITE
>
> -#define DUMP_WRITE(addr, nr) Â \
> - Â Â Â if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \
> - Â Â Â Â Â Â Â goto end_coredump;
> -
> Âstatic void fill_elf_header(struct elfhdr *elf, int segs,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Âu16 machine, u32 flags, u8 osabi)
> Â{
> @@ -1981,7 +1977,10 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
> Â Â Â Âfs = get_fs();
> Â Â Â Âset_fs(KERNEL_DS);
>
> - Â Â Â DUMP_WRITE(elf, sizeof(*elf));
> + Â Â Â size += sizeof(*elf);
> + Â Â Â if (size > limit || !dump_write(file, elf, sizeof(*elf)))
> + Â Â Â Â Â Â Â goto end_coredump;
> +
> Â Â Â Âoffset += sizeof(*elf); Â Â Â Â Â Â Â Â Â Â Â Â /* Elf header */
> Â Â Â Âoffset += (segs + 1) * sizeof(struct elf_phdr); /* Program headers */
> Â Â Â Âfoffset = offset;
> @@ -1995,7 +1994,9 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
>
> Â Â Â Â Â Â Â Âfill_elf_note_phdr(&phdr, sz, offset);
> Â Â Â Â Â Â Â Âoffset += sz;
> - Â Â Â Â Â Â Â DUMP_WRITE(&phdr, sizeof(phdr));
> + Â Â Â Â Â Â Â size += sizeof(phdr);
> + Â Â Â Â Â Â Â if (size > limit || !dump_write(file, &phdr, sizeof(phdr)))
> + Â Â Â Â Â Â Â Â Â Â Â goto end_coredump;
> Â Â Â Â}
>
> Â Â Â Âdataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
> @@ -2026,7 +2027,9 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
> Â Â Â Â Â Â Â Â Â Â Â Âphdr.p_flags |= PF_X;
> Â Â Â Â Â Â Â Âphdr.p_align = ELF_EXEC_PAGESIZE;
>
> - Â Â Â Â Â Â Â DUMP_WRITE(&phdr, sizeof(phdr));
> + Â Â Â Â Â Â Â size += sizeof(phdr);
> + Â Â Â Â Â Â Â if (size > limit || !dump_write(file, &phdr, sizeof(phdr)))
> + Â Â Â Â Â Â Â Â Â Â Â goto end_coredump;
> Â Â Â Â}
>
> Â Â Â Âif (!elf_core_write_extra_phdrs(file, offset, &size, limit))
> --
> 1.6.5.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/