Re: [PATCH] Kill __bzero()

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

 



On Sun, Nov 04, 2007 at 09:18:32AM +0100, Franck Bui-Huu wrote:

>   1/ Its unconventional prototype is error prone: its prototype is
>   the same as memset one but was documented by mips_ksym.c like the
>   following:
> 
> 	   extern void *__bzero(void *__s, size_t __count);
> 
>   2/ For the caller, it makes no difference to call memset instead
>   since it has to setup the second parameter of __bzero to 0.
> 
>   3/ It's not part of the Linux user access API, so no module can use
>   it.
> 
>   4/ It needs to be exported with EXPORT_SYMBOL and therefore consumes
>   some extra bytes.
> 
>   5/ It has only one user.
> 
> Signed-off-by: Franck Bui-Huu <fbuihuu@xxxxxxxxx>
> ---
> 
>  I'm wondering if I'm missing something, because this function seems
>  so ugly and useless in the first place, that I can't refrain to
>  submit a patch to get rid of it.

Memset is almost always only ever invoked with a zero argument.  So the
idea was to have something like this:

extern void *__memset(void *__s, int __c, size_t __count);
extern void *bzero(void *__s, size_t __count);

static inline void *memset(void *s, int c, size_t count)
{
	if (__builtin_constant_p(c) && c == 0) {
		bzero(s, count);
		return s;
	} else
		return __memset(s, __c, count);
}

But that was never quite implemented like this as you noticed.

As for the differences in the return value, they're because of of
clear_user and __clear_user which return the number of bytes that could
_not_ be cleared in $a2.  Memset being invoked through the normal C calling
conventions ignores this value while it's the actual result of interest for
__clear_user.

I hope that explains things a little.

  Ralf


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux