Re: Query : siginitsetinv/siginitset has a memset of size 0

From: Richard Weinberger
Date: Thu Jul 21 2016 - 11:52:20 EST


On Thu, Jul 21, 2016 at 5:12 PM, pavi1729 <pavitra1729@xxxxxxxxx> wrote:
> Hi,
> signal.h code and a memset of size 0, is that fine or am I missing something ?

When _NSIG_WORDS is 1 you enter case 1: which is a nop, so the memset()
is not being executed.

>
> http://lxr.free-electrons.com/source/include/linux/signal.h
>
> 200 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
> 201 {
> 202 set->sig[0] = ~mask;
> 203 switch (_NSIG_WORDS) {
> 204 default:
> 205 memset(&set->sig[1], -1,
> sizeof(long)*(_NSIG_WORDS-1)); <-- size 0
> 206 break;
> 207 case 2: set->sig[1] = -1;
> 208 case 1: ;
> 209 }
> 210 }
>
>
> http://lxr.free-electrons.com/source/arch/ia64/include/asm/signal.h#L16
> 14 #define _NSIG 64
> 15 #define _NSIG_BPW 64
> 16 #define _NSIG_WORDS (_NSIG / _NSIG_BPW)
> 17
>
>
> Thanks,
> Pavi



--
Thanks,
//richard