On Mon, 2014-03-17 at 08:31 -0700, Linus Torvalds wrote: > On Mon, Mar 17, 2014 at 8:13 AM, Dirk Hohndel <d...@hohndel.org> wrote: > > > > Look at this little gem. I think I'll reorder this a little bit: > > No need. > > > +static inline int number_of_computers(struct dive *dive) > > +{ > > + int total_number = 0; > > + struct divecomputer *dc = &dive->dc; > > + > > + if (!dive) > > + return 1; > > > > (hint: think what happens if dive == null) > > Absolutely nothing happens. > > It does not *access* the dive pointer. It just creates a new pointer > *offset* from the dive pointer. > > Doing "&ptr->xyz" is just pointer arithmetic. It may syntactically > look like an access due to the "->", but it really isn't. It literally > means "calculate the address of the field xyz in the structure pointed > to by ptr".
Some days I hate the details of pointer arithmetic. I guess you are right. I reordered it anyway because otherwise I'll stumble across it next time I look at it :-) /D _______________________________________________ subsurface mailing list subsurface@hohndel.org http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface