Re: [Linuxptp-devel] [PATCHv2 4/9] rtnl: add function rtnl_link_info
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Richard C. <ric...@gm...> - 2017-08-05 08:31:59
|
On Sat, Jul 15, 2017 at 09:33:06PM +0800, Hangbin Liu wrote: > @@ -92,6 +151,18 @@ int rtnl_link_status(int fd, rtnl_callback cb, void *ctx) > struct msghdr msg; > struct nlmsghdr *nh; > struct ifinfomsg *info = NULL; > + char *device; > + struct rtattr *tb[IFLA_MAX+1]; > + > + if (cb) > + device = calloc(1, sizeof(MAX_IFNAME_SIZE + 1)); > + else > + device = (char *)ctx; The meaning of 'ctx' changes according to the value of 'cb'. This overloading of the function arguments is gross. Please find another way to structure this. You only have two call paths for rtnl_link_status: 1. port_event() -> rtnl_link_status() 2. clock_create() -> rtnl_link_info() -> rtnl_link_status() Thanks, Richard |