rtnl: Constify the public interface.

Three of the rtnl methods never modify the strings passed in.  This
patch adds the const keyword to ensure these functions stay that way.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
master
Richard Cochran 2020-02-09 07:19:27 -08:00
parent 831f7e073b
commit e4d1988f54
2 changed files with 6 additions and 6 deletions

6
rtnl.c
View File

@ -87,7 +87,7 @@ static void rtnl_get_ts_device_callback(void *ctx, int linkup, int ts_index)
*dst = ts_index; *dst = ts_index;
} }
int rtnl_get_ts_device(char *device, char *ts_device) int rtnl_get_ts_device(const char *device, char *ts_device)
{ {
int err, fd; int err, fd;
int ts_index = -1; int ts_index = -1;
@ -112,7 +112,7 @@ no_info:
return err; return err;
} }
int rtnl_link_query(int fd, char *device) int rtnl_link_query(int fd, const char *device)
{ {
struct sockaddr_nl sa; struct sockaddr_nl sa;
struct msghdr msg; struct msghdr msg;
@ -227,7 +227,7 @@ static int rtnl_linkinfo_parse(int master_index, struct rtattr *rta)
return index; return index;
} }
int rtnl_link_status(int fd, char *device, rtnl_callback cb, void *ctx) int rtnl_link_status(int fd, const char *device, rtnl_callback cb, void *ctx)
{ {
struct rtattr *tb[IFLA_MAX+1]; struct rtattr *tb[IFLA_MAX+1];
struct ifinfomsg *info = NULL; struct ifinfomsg *info = NULL;

6
rtnl.h
View File

@ -37,7 +37,7 @@ int rtnl_close(int fd);
* at least IF_NAMESIZE bytes long. * at least IF_NAMESIZE bytes long.
* @return Zero on success, or -1 on error. * @return Zero on success, or -1 on error.
*/ */
int rtnl_get_ts_device(char *device, char *ts_device); int rtnl_get_ts_device(const char *device, char *ts_device);
/** /**
* Request the link status from the kernel. * Request the link status from the kernel.
@ -45,7 +45,7 @@ int rtnl_get_ts_device(char *device, char *ts_device);
* @param device Interface name. Request all iface's status if set NULL. * @param device Interface name. Request all iface's status if set NULL.
* @return Zero on success, non-zero otherwise. * @return Zero on success, non-zero otherwise.
*/ */
int rtnl_link_query(int fd, char *device); int rtnl_link_query(int fd, const char *device);
/** /**
* Read kernel messages looking for a link up/down events. * Read kernel messages looking for a link up/down events.
@ -55,7 +55,7 @@ int rtnl_link_query(int fd, char *device);
* @param ctx Private context passed to the callback. * @param ctx Private context passed to the callback.
* @return Zero on success, non-zero otherwise. * @return Zero on success, non-zero otherwise.
*/ */
int rtnl_link_status(int fd, char *device, rtnl_callback cb, void *ctx); int rtnl_link_status(int fd, const char *device, rtnl_callback cb, void *ctx);
/** /**
* Open a RT netlink socket for monitoring link state. * Open a RT netlink socket for monitoring link state.