lkml.org 
[lkml]   [2016]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 1/6] rtc: generic: allow building on all architectures
Date
On Wednesday 02 March 2016 09:57:27 Geert Uytterhoeven wrote:
> > @@ -33,13 +35,21 @@ static const struct rtc_class_ops generic_rtc_ops = {
> > .read_time = generic_get_time,
> > .set_time = generic_set_time,
> > };
> > +#else
> > +#define generic_rtc_ops *(struct rtc_class_ops*)NULL
> > +#endif
> >
> > static int __init generic_rtc_probe(struct platform_device *dev)
> > {
> > struct rtc_device *rtc;
> > + const struct rtc_class_ops *ops;
> > +
> > + ops = dev_get_platdata(&dev->dev);
> > + if (!ops)
> > + ops = &generic_rtc_ops;
>
> I hope no compiler version treats "&*(struct rtc_class_ops*)NULL" as
> undefined behavior?

It's a bit odd, but I think it's syntactically correct C, and not
much too different from

#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)

is it? My last patch gets rid of it again.

Arnd

\
 
 \ /
  Last update: 2016-03-02 10:42    [W:0.048 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site