lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTimCHUmEJ7wFbSF80Fz3b-nyr_PGqbJ5iq4uNSGF@mail.gmail.com>
Date:	Mon, 31 Jan 2011 15:23:33 -0500
From:	Sri Ram Vemulpali <sri.ram.gmu06@...il.com>
To:	Manish Katiyar <mkatiyar@...il.com>
Cc:	Kernel-newbies <kernelnewbies@...linux.org>,
	linux-kernel-mail <linux-kernel@...r.kernel.org>
Subject: Re: typecheck code

Thanks for all explanation. It really helped to understand.

Sri

On Mon, Jan 31, 2011 at 1:03 PM, Manish Katiyar <mkatiyar@...il.com> wrote:
> On Mon, Jan 31, 2011 at 9:03 AM, Sri Ram Vemulpali
> <sri.ram.gmu06@...il.com> wrote:
>> Hi all,
>>
>> /*
>>  * Check at compile time that something is of a particular type.
>>  * Always evaluates to 1 so you may use it easily in comparisons.
>>  */
>>  #define typecheck(type,x) \
>>  ({      type __dummy; \
>>        typeof(x) __dummy2; \
>>        (void)(&__dummy == &__dummy2); \
>>        1; \
>>  })
>>
>> #define typecheck_fn(type,function) \
>> ({      typeof(type) __tmp = function; \
>>       (void)__tmp; \
>> })
>>
>> Can anyone help me, explain the above code typecheck. How does
>> (void)(&__dummy == &__dummy2) evaluates to 1
>
> Infact I think it will never return 1, since the addresses of __dummy1
> and __dummy2 have to be different (off by 4 or 8). As pointed out it
> is the next line that always returns 1. The purpose of this line is to
> throw away warnings like "Incompatible pointer comparison" or
> something like that (haven't tried :-)) incase there is a mismatch.
>
> --
> Thanks -
> Manish
>



-- 
Regards,
Sri.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ