Re: [PATCH] Kill a sparse warning in binfmt_elf.c

From: Valdis . Kletnieks
Date: Thu Oct 07 2004 - 14:10:09 EST


On Thu, 07 Oct 2004 11:49:24 PDT, Arun Sharma said:

> >> static int dump_write(struct file *file, const void *addr, int nr)
> >> {
> >> - return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
> >> + return file->f_op->write(file, (const char __user *) addr, nr, &file->f
_pos) == nr;
> >> }
> >
> > wouldn't it be more useful to put the annotation into the *prototype* for
> > the dump_write() function, so that we get sparse typechecking for the
> > caller(s) of this function? Your fix just kills the warning - when the *re
al*
> > problem is that we're called with a 'void *' that we then cast to something
> > without any real double check on what it is....
>
> dump_write() is a static function without a prototype.

static int dump_write(struct file *file, const char __user *addr, int nr)
{
return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
}

And then go find the callers and make sure what they're passing is a
'const char __user *' rather than a 'const void *'....

Attachment: pgp00000.pgp
Description: PGP signature