Re: [GIT] Networking

Rustad, Mark D
2015-09-04T17:38:58Z

[-- Attachment #1: Type: text/plain, Size: 1190 bytes --]

> On Sep 4, 2015, at 2:07 AM, David Laight <David.Laight@ACULAB.COM> wrote:
>
>> I find them useful as syntactic sugar. We have not used them a lot, but there are cases in our crypto
>> handling code where we have fixed size array inputs/outputs and there we opted to use them. They make
>> it easy to remember what the expected sizes of input and output are without having to read through the
>> implementation (of course we never even tried to use sizeof on these pointers).
>>
>> static int smp_ah(struct crypto_blkcipher *tfm, const u8 irk[16],
>> const u8 r[3], u8 res[3])
>
> Expect that it looks like you are passing arrays by value,
> but instead you are passing by reference.
>
> Explicitly pass by reference and sizeof works.

It depends on what you mean by works. It at least doesn't look so misleading when passing by reference and so works more as expected. The sizeof in either case will never return the size of the array. To have sizeof return the size of the array would require a typedef of the array to pass by reference. In some cases that could be the right thing to do.

--
Mark Rustad, Networking Division, Intel Corporation

[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 841 bytes --]