Re: [PATCH] binfmt_elf CodingStyle cleanup and remove some pointless casts

From: Jesper Juhl
Date: Mon Apr 24 2006 - 17:50:24 EST


On Monday 24 April 2006 22:32, Andrew Morton wrote:
> Jesper Juhl <jesper.juhl@xxxxxxxxx> wrote:
> >
> > We still need to cast u_platform from pointer to integer or gcc will yell
> > at us. But, I don't see why we should first cast it to `unsigned long' and
> > then to elf_addr_t, so I removed the `unsigned long' cast.
>
> On 64 bit platforms, these:
>
> some_pointer = (something *)some_u32;
> some_u32 = (u32)pointer;
>
> will generate compile warnings concerning the differently-sized quantities
> on the lhs and rhs.
>
> The usual way of suppressing this is
>
> some_pointer = (something *)(unsigned long)some_u32;
> some_u32 = (unsigned long)pointer;
>

I see. Thank you for the info, I had not considered that, but it makes sense.
The patch should look like below, then.


Remove redundant casts from NEW_AUX_ENT() arguments in fs/binfmt_elf.c

Signed-off-by: Jesper Juhl <jesper.juhl@xxxxxxxxx>
---

fs/binfmt_elf.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)

--- linux-2.6.17-rc2-git4/fs/binfmt_elf.c.old 2006-04-24 19:21:14.000000000 +0200
+++ linux-2.6.17-rc2-git4/fs/binfmt_elf.c 2006-04-24 23:47:23.000000000 +0200
@@ -177,10 +177,11 @@ create_elf_tables(struct linux_binprm *b
}

/* Create the ELF interpreter info */
- elf_info = (elf_addr_t *) current->mm->saved_auxv;
+ elf_info = (elf_addr_t *)current->mm->saved_auxv;
#define NEW_AUX_ENT(id, val) \
do { \
- elf_info[ei_index++] = id; elf_info[ei_index++] = val; \
+ elf_info[ei_index++] = id; \
+ elf_info[ei_index++] = val; \
} while (0)

#ifdef ARCH_DLINFO
@@ -199,17 +200,17 @@ create_elf_tables(struct linux_binprm *b
NEW_AUX_ENT(AT_BASE, interp_load_addr);
NEW_AUX_ENT(AT_FLAGS, 0);
NEW_AUX_ENT(AT_ENTRY, exec->e_entry);
- NEW_AUX_ENT(AT_UID, (elf_addr_t)tsk->uid);
- NEW_AUX_ENT(AT_EUID, (elf_addr_t)tsk->euid);
- NEW_AUX_ENT(AT_GID, (elf_addr_t)tsk->gid);
- NEW_AUX_ENT(AT_EGID, (elf_addr_t)tsk->egid);
- NEW_AUX_ENT(AT_SECURE, (elf_addr_t)security_bprm_secureexec(bprm));
+ NEW_AUX_ENT(AT_UID, tsk->uid);
+ NEW_AUX_ENT(AT_EUID, tsk->euid);
+ NEW_AUX_ENT(AT_GID, tsk->gid);
+ NEW_AUX_ENT(AT_EGID, tsk->egid);
+ NEW_AUX_ENT(AT_SECURE, security_bprm_secureexec(bprm));
if (k_platform) {
NEW_AUX_ENT(AT_PLATFORM,
- (elf_addr_t)(unsigned long)u_platform);
+ (elf_addr_t)(unsigned long)u_platform);
}
if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) {
- NEW_AUX_ENT(AT_EXECFD, (elf_addr_t)bprm->interp_data);
+ NEW_AUX_ENT(AT_EXECFD, bprm->interp_data);
}
#undef NEW_AUX_ENT
/* AT_NULL is zero; clear the rest too */



-
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/