Messages in this thread | | | Date | Fri, 27 May 2011 08:38:05 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH 10/12] x86, mce: cleanup mce_read |
| |
On Fri, May 27, 2011 at 01:11:34PM +0900, Hidetoshi Seto wrote: > Use temporary local entry to make code simple. > No change in logic. > > Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> > --- > arch/x86/kernel/cpu/mcheck/mce.c | 19 +++++++++---------- > 1 files changed, 9 insertions(+), 10 deletions(-) > > diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c > index 9fe9e6e..4ba4040 100644 > --- a/arch/x86/kernel/cpu/mcheck/mce.c > +++ b/arch/x86/kernel/cpu/mcheck/mce.c > @@ -1533,18 +1533,17 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, > do { > for (i = prev; i < next; i++) { > unsigned long start = jiffies; > + struct mce *entry = &mcelog.entry[i];
Just go ahead and call it m:
struct mce *m = ...
we know it's an mce struct.
> > - while (!mcelog.entry[i].finished) { > + while (!entry->finished) { > if (time_after_eq(jiffies, start + 2)) { > - memset(mcelog.entry + i, 0, > - sizeof(struct mce)); > + memset(entry, 0, sizeof(struct mce));
..and thus you can do
memset(m, 0, sizeof(*m));
and that's too short for some taste but since the definition is close enough, we should still be readable.
> goto timeout; > } > cpu_relax(); > } > smp_rmb(); > - err |= copy_to_user(buf, mcelog.entry + i, > - sizeof(struct mce)); > + err |= copy_to_user(buf, entry, sizeof(struct mce)); > buf += sizeof(struct mce); > timeout: > ; > @@ -1565,13 +1564,13 @@ timeout: > on_each_cpu(collect_tscs, cpu_tsc, 1); > > for (i = next; i < MCE_LOG_LEN; i++) { > - if (mcelog.entry[i].finished && > - mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) { > - err |= copy_to_user(buf, mcelog.entry+i, > - sizeof(struct mce)); > + struct mce *entry = &mcelog.entry[i]; > + > + if (entry->finished && entry->tsc < cpu_tsc[entry->cpu]) { > + err |= copy_to_user(buf, entry, sizeof(struct mce)); > smp_rmb(); > buf += sizeof(struct mce); > - memset(&mcelog.entry[i], 0, sizeof(struct mce)); > + memset(entry, 0, sizeof(struct mce)); > } > } > > -- > 1.7.1 > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/
-- Regards/Gruss, Boris.
| |