Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1220056 > unrolled thread

RE: [GIT] Networking

Started byDavid Laight <David.Laight@ACULAB.COM>
First post2015-09-07 13:10 +0200
Last post2015-09-08 19:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  RE: [GIT] Networking David Laight <David.Laight@ACULAB.COM> - 2015-09-07 13:10 +0200
    Re: [GIT] Networking "Rustad, Mark D" <mark.d.rustad@intel.com> - 2015-09-08 19:00 +0200

#1220056 — RE: [GIT] Networking

FromDavid Laight <David.Laight@ACULAB.COM>
Date2015-09-07 13:10 +0200
SubjectRE: [GIT] Networking
Message-ID<q62tc-3L3-7@gated-at.bofh.it>
From: Rustad, Mark D
...
> >> 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.

Feed:
int bar(int (*f)[10]) { return sizeof *f; }
into cc -O2 -S and look at the generated code - returns 40 not 4.

	David

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

[toc] | [next] | [standalone]


#1220996

From"Rustad, Mark D" <mark.d.rustad@intel.com>
Date2015-09-08 19:00 +0200
Message-ID<q6upt-1Fu-23@gated-at.bofh.it>
In reply to#1220056

[Multipart message — attachments visible in raw view] — view raw

> On Sep 7, 2015, at 4:02 AM, David Laight <David.Laight@ACULAB.COM> wrote:
> 
> Feed:
> int bar(int (*f)[10]) { return sizeof *f; }
> into cc -O2 -S and look at the generated code - returns 40 not 4.

Yes, indeed it does. And with clang too. I guess I was too easily discouraged when looking for a workable syntax some years ago. At the time I stopped when the typedef worked, which really just encapsulates this. I should have recognized that then. Thanks for making it all so clear.

--
Mark Rustad, Networking Division, Intel Corporation

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web