Re: [PATCH 7/16] Let void have sizeof 1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 24, 2008 at 03:26, Derek M Jones <derek@xxxxxxxxxxxx> wrote:
> Alexey,
>
> I have been looking through the source to look at the contexts
> in which arithmetic is performed on void pointers.
>
>>>  1) Are the arguments really chars of one sort or another and
>>> therefore the parameter ought to be declared as such?
>>
>> You mean, if address arithmetics is performed on a void * cast result,
>> check that the casted type too has sizeof 1?
>
> I was thinking more along the lines of pointer to a character type being
> converted to void * for no obvious reason, or a value being converted to
> void * having an arithmetic operation performed and then converted to
> a pointer to character type.
> For an example see line 156 of arch/x86/kernel/module_64.
>
> I would expect the void * to come from/go to a type that had a
> size greater than 1.
>
>>>  4) Other possible fault issues, people?
>
> I have found an instance (arch/x86/kernel/kprobes.c:834) that
> effectively does:
>
> (void *)long_val + an_int_calculation
>
> when it should have done:
>
> (void *)(long_val + an_int_calculation)
>
> hardly an earth shattering misuse.
There is nothing wrong here. Just depends on the way you think
about it. In the first case you convert a long to a pointer, and add
an int, the the second, you convert the sum. The result is of course
the same. And this has nothing to do with void*, it would be the
same with char*.

So far the only concern with void* is that not everyone knows
the it is sizeof 1. So if you propose repulsing void* with char*
when we don't really need a void*, that's probably fine. But don't
you think there are more useful ways to spend your time?
With open issues like the Global Warming, World Hunger and
standing 2.6.28 regressions, I don't see anyone bothered with
replacing unnecessary void* casts.
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux