* [PATCH 1/1] of: Make return types of to_of_node and of_fwnode_handle macros consistent [not found] <2117711.dO2rQLXOup@avalon> @ 2017-11-02 9:57 ` Sakari Ailus 2017-11-02 9:59 ` [RESEND PATCH " Sakari Ailus 1 sibling, 0 replies; 4+ messages in thread From: Sakari Ailus @ 2017-11-02 9:57 UTC (permalink / raw) To: devicetree-u79uwXL29TY76Z2rM5mHXA, m.chehab-JPH+aEBZ4P+UEJcrhfAQsw Cc: linux-media-u79uwXL29TY76Z2rM5mHXA, laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, robh-DgEjT+Ai2ygdnm+yROfE0A, hyun.kwon-gjFFaj9aHVfQT0dZR+AlfA, soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r to_of_node() macro checks whether the fwnode_handle passed to it is not an OF node, and if so, returns NULL in order to be NULL-safe. Otherwise it returns the pointer to the OF node which the fwnode_handle contains. The problem with returning NULL is that its type was void *, which sometimes matters. Explicitly return struct device_node * instead. Make a similar change to of_fwnode_handle() as well. Fixes: d20dc1493db4 ("of: Support const and non-const use for to_of_node()") Fixes: debd3a3b27c7 ("of: Make of_fwnode_handle() safer") Signed-off-by: Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> --- Hi Mauro, Could you check whether this addresses the smatch issue with the xilinx driver? Thanks. include/linux/of.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/of.h b/include/linux/of.h index b240ed69dc96..0651231c115e 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -161,7 +161,7 @@ static inline bool is_of_node(const struct fwnode_handle *fwnode) is_of_node(__to_of_node_fwnode) ? \ container_of(__to_of_node_fwnode, \ struct device_node, fwnode) : \ - NULL; \ + (struct device_node *)NULL; \ }) #define of_fwnode_handle(node) \ @@ -169,7 +169,8 @@ static inline bool is_of_node(const struct fwnode_handle *fwnode) typeof(node) __of_fwnode_handle_node = (node); \ \ __of_fwnode_handle_node ? \ - &__of_fwnode_handle_node->fwnode : NULL; \ + &__of_fwnode_handle_node->fwnode : \ + (struct fwnode_handle *)NULL; \ }) static inline bool of_have_populated_dt(void) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RESEND PATCH 1/1] of: Make return types of to_of_node and of_fwnode_handle macros consistent [not found] <2117711.dO2rQLXOup@avalon> 2017-11-02 9:57 ` [PATCH 1/1] of: Make return types of to_of_node and of_fwnode_handle macros consistent Sakari Ailus @ 2017-11-02 9:59 ` Sakari Ailus 2017-11-02 17:37 ` Laurent Pinchart 2017-11-06 21:45 ` Rob Herring 1 sibling, 2 replies; 4+ messages in thread From: Sakari Ailus @ 2017-11-02 9:59 UTC (permalink / raw) To: devicetree-u79uwXL29TY76Z2rM5mHXA, mchehab-JsYNTwtnfakRB7SZvlqPiA Cc: linux-media-u79uwXL29TY76Z2rM5mHXA, laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, robh-DgEjT+Ai2ygdnm+yROfE0A, hyun.kwon-gjFFaj9aHVfQT0dZR+AlfA, soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r (Fixed Mauro's e-mail.) to_of_node() macro checks whether the fwnode_handle passed to it is not an OF node, and if so, returns NULL in order to be NULL-safe. Otherwise it returns the pointer to the OF node which the fwnode_handle contains. The problem with returning NULL is that its type was void *, which sometimes matters. Explicitly return struct device_node * instead. Make a similar change to of_fwnode_handle() as well. Fixes: d20dc1493db4 ("of: Support const and non-const use for to_of_node()") Fixes: debd3a3b27c7 ("of: Make of_fwnode_handle() safer") Signed-off-by: Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> --- Hi Mauro, Could you check whether this addresses the smatch issue with the xilinx driver? Thanks. include/linux/of.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/of.h b/include/linux/of.h index b240ed69dc96..0651231c115e 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -161,7 +161,7 @@ static inline bool is_of_node(const struct fwnode_handle *fwnode) is_of_node(__to_of_node_fwnode) ? \ container_of(__to_of_node_fwnode, \ struct device_node, fwnode) : \ - NULL; \ + (struct device_node *)NULL; \ }) #define of_fwnode_handle(node) \ @@ -169,7 +169,8 @@ static inline bool is_of_node(const struct fwnode_handle *fwnode) typeof(node) __of_fwnode_handle_node = (node); \ \ __of_fwnode_handle_node ? \ - &__of_fwnode_handle_node->fwnode : NULL; \ + &__of_fwnode_handle_node->fwnode : \ + (struct fwnode_handle *)NULL; \ }) static inline bool of_have_populated_dt(void) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RESEND PATCH 1/1] of: Make return types of to_of_node and of_fwnode_handle macros consistent 2017-11-02 9:59 ` [RESEND PATCH " Sakari Ailus @ 2017-11-02 17:37 ` Laurent Pinchart 2017-11-06 21:45 ` Rob Herring 1 sibling, 0 replies; 4+ messages in thread From: Laurent Pinchart @ 2017-11-02 17:37 UTC (permalink / raw) To: Sakari Ailus Cc: devicetree, mchehab, linux-media, robh, hyun.kwon, soren.brinkmann, linux-arm-kernel Hi Sakari, Thank you for the patch. On Thursday, 2 November 2017 11:59:18 EET Sakari Ailus wrote: > (Fixed Mauro's e-mail.) > > to_of_node() macro checks whether the fwnode_handle passed to it is not an > OF node, and if so, returns NULL in order to be NULL-safe. Otherwise it > returns the pointer to the OF node which the fwnode_handle contains. > > The problem with returning NULL is that its type was void *, which > sometimes matters. Explicitly return struct device_node * instead. > > Make a similar change to of_fwnode_handle() as well. > > Fixes: d20dc1493db4 ("of: Support const and non-const use for to_of_node()") > Fixes: debd3a3b27c7 ("of: Make of_fwnode_handle() safer") > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > Hi Mauro, > > Could you check whether this addresses the smatch issue with the xilinx > driver? > > Thanks. > > include/linux/of.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/include/linux/of.h b/include/linux/of.h > index b240ed69dc96..0651231c115e 100644 > --- a/include/linux/of.h > +++ b/include/linux/of.h > @@ -161,7 +161,7 @@ static inline bool is_of_node(const struct fwnode_handle > *fwnode) is_of_node(__to_of_node_fwnode) ? \ > container_of(__to_of_node_fwnode, \ > struct device_node, fwnode) : \ > - NULL; \ > + (struct device_node *)NULL; \ > }) > > #define of_fwnode_handle(node) \ > @@ -169,7 +169,8 @@ static inline bool is_of_node(const struct fwnode_handle > *fwnode) typeof(node) __of_fwnode_handle_node = (node); \ > \ > __of_fwnode_handle_node ? \ > - &__of_fwnode_handle_node->fwnode : NULL; \ > + &__of_fwnode_handle_node->fwnode : \ > + (struct fwnode_handle *)NULL; \ > }) > > static inline bool of_have_populated_dt(void) -- Regards, Laurent Pinchart ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RESEND PATCH 1/1] of: Make return types of to_of_node and of_fwnode_handle macros consistent 2017-11-02 9:59 ` [RESEND PATCH " Sakari Ailus 2017-11-02 17:37 ` Laurent Pinchart @ 2017-11-06 21:45 ` Rob Herring 1 sibling, 0 replies; 4+ messages in thread From: Rob Herring @ 2017-11-06 21:45 UTC (permalink / raw) To: Sakari Ailus Cc: devicetree, mchehab, linux-media, laurent.pinchart, hyun.kwon, soren.brinkmann, linux-arm-kernel On Thu, Nov 02, 2017 at 11:59:18AM +0200, Sakari Ailus wrote: > (Fixed Mauro's e-mail.) > > to_of_node() macro checks whether the fwnode_handle passed to it is not an > OF node, and if so, returns NULL in order to be NULL-safe. Otherwise it > returns the pointer to the OF node which the fwnode_handle contains. > > The problem with returning NULL is that its type was void *, which > sometimes matters. Explicitly return struct device_node * instead. > > Make a similar change to of_fwnode_handle() as well. > > Fixes: d20dc1493db4 ("of: Support const and non-const use for to_of_node()") > Fixes: debd3a3b27c7 ("of: Make of_fwnode_handle() safer") > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > --- > Hi Mauro, > > Could you check whether this addresses the smatch issue with the xilinx > driver? > > Thanks. > > include/linux/of.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-06 21:45 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <2117711.dO2rQLXOup@avalon> 2017-11-02 9:57 ` [PATCH 1/1] of: Make return types of to_of_node and of_fwnode_handle macros consistent Sakari Ailus 2017-11-02 9:59 ` [RESEND PATCH " Sakari Ailus 2017-11-02 17:37 ` Laurent Pinchart 2017-11-06 21:45 ` Rob Herring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).