From 469dd9623a293a683a8faaf5ffaba6837b920955 Mon Sep 17 00:00:00 2001 From: Shahbaz Youssefi Date: Mon, 21 Dec 2015 10:56:49 -0500 Subject: [PATCH] Be able to take string literal as ifname `ifname` as the argument of `ec_init` and related functions is not changed, and therefore can be safely retyped to `const char *`. This allows using string literals. For example: ec_init(argc > 1 ? argv[1] : "eth0"); Signed-off-by: Shahbaz Youssefi --- soem/ethercatmain.c | 8 ++++---- soem/ethercatmain.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/soem/ethercatmain.c b/soem/ethercatmain.c index 3e8bde0..e8314dd 100644 --- a/soem/ethercatmain.c +++ b/soem/ethercatmain.c @@ -321,7 +321,7 @@ static void ecx_mbxemergencyerror(ecx_contextt *context, uint16 Slave,uint16 Err * @param[in] ifname = Dev name, f.e. "eth0" * @return >0 if OK */ -int ecx_init(ecx_contextt *context, char * ifname) +int ecx_init(ecx_contextt *context, const char * ifname) { return ecx_setupnic(context->port, ifname, FALSE); } @@ -333,7 +333,7 @@ int ecx_init(ecx_contextt *context, char * ifname) * @param[in] if2name = Secondary Dev name, f.e. "eth1" * @return >0 if OK */ -int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, char *ifname, char *if2name) +int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, const char *ifname, char *if2name) { int rval, zbuf; ec_etherheadert *ehp; @@ -1905,7 +1905,7 @@ void ec_packeterror(uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode) * @return >0 if OK * @see ecx_init */ -int ec_init(char * ifname) +int ec_init(const char * ifname) { return ecx_init(&ecx_context, ifname); } @@ -1916,7 +1916,7 @@ int ec_init(char * ifname) * @return >0 if OK * @see ecx_init_redundant */ -int ec_init_redundant(char *ifname, char *if2name) +int ec_init_redundant(const char *ifname, char *if2name) { return ecx_init_redundant (&ecx_context, &ecx_redport, ifname, if2name); } diff --git a/soem/ethercatmain.h b/soem/ethercatmain.h index ea0b776..766bc60 100644 --- a/soem/ethercatmain.h +++ b/soem/ethercatmain.h @@ -473,8 +473,8 @@ void ec_pusherror(const ec_errort *Ec); boolean ec_poperror(ec_errort *Ec); boolean ec_iserror(void); void ec_packeterror(uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode); -int ec_init(char * ifname); -int ec_init_redundant(char *ifname, char *if2name); +int ec_init(const char * ifname); +int ec_init_redundant(const char *ifname, char *if2name); void ec_close(void); uint8 ec_siigetbyte(uint16 slave, uint16 address); int16 ec_siifind(uint16 slave, uint16 cat); @@ -514,8 +514,8 @@ void ecx_pusherror(ecx_contextt *context, const ec_errort *Ec); boolean ecx_poperror(ecx_contextt *context, ec_errort *Ec); boolean ecx_iserror(ecx_contextt *context); void ecx_packeterror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode); -int ecx_init(ecx_contextt *context, char * ifname); -int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, char *ifname, char *if2name); +int ecx_init(ecx_contextt *context, const char * ifname); +int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, const char *ifname, char *if2name); void ecx_close(ecx_contextt *context); uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address); int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat);