Merge pull request #146 from EuropeanSpallationSource/190920_send_mess_uses_const_char

The 2nd and 3rd parameter in send_mess() can and should
be a 'const char *' instead of just 'char *'.
Modern compilers complain here, so that the signature now
gets the const.

Update drivers from the following list to use the new send_mess():
modules/motorAcs
modules/motorAcsTech80
modules/motorAerotech
modules/motorFaulhaber
modules/motorIms
modules/motorKohzu
modules/motorMclennan
modules/motorMicos
modules/motorMicroMo
modules/motorNewFocus
modules/motorNewport
modules/motorOms
modules/motorOriel
modules/motorPI
modules/motorParker
modules/motorPiJena
modules/motorSmartMotor
modules/motorThorLabs

And while there, fix one more "const char *" in motordrvCom.cc
This commit is contained in:
Kevin Peterson
2019-09-30 11:06:37 -05:00
committed by GitHub
21 changed files with 34 additions and 21 deletions
+13
View File
@@ -219,6 +219,19 @@ Modification Log for R6-10
File modified: OmsSrc/drvMAXv.cc
8) Changed axis names from 'char *' to 'const char*' to avoid compiler warnings.
(Assigning literal string to char* is deprecated).
This affects driver_table.axis_names and driver_table.sendmsg used in
every motor driver.
*** THIS CHANGE BREAKS BACKWARD COMPATIBILITY! ***
All external motor drivers need to change their send_mess() function
to use 'const char*' as the last argument:
RTN_STATUS send_mess(int, const char *, const char *);
Files modified: motorApp/MotorSrc/motordrvCom.h
motorApp/MotorSrc/motordrvCom.cc
motorApp/*Src/drv*.cc
Modification Log for R6-9
=========================
+1 -1
View File
@@ -312,7 +312,7 @@ static void process_messages(struct driver_table *tabptr, epicsTime tick,
struct mess_info *motor_info;
struct controller *brdptr;
char inbuf[MAX_MSG_SIZE];
char *axis_name;
const char *axis_name;
if (tabptr->axis_names == NULL)
axis_name = (char *) NULL;
+2 -2
View File
@@ -196,13 +196,13 @@ struct driver_table
struct controller ***card_array;
int *cardcnt_ptr;
int *any_inmotion_ptr;
RTN_STATUS (*sendmsg) (int, char const *, char *);
RTN_STATUS (*sendmsg) (int, const char *, const char *);
int (*getmsg) (int, char *, int);
int (*setstat) (int, int);
void (*query_done) (int, int, struct mess_node *);
void (*strtstat) (int); /* Optional; start status function or NULL. */
const bool *const init_indicator; /* Driver initialized indicator. */
char **axis_names; /* Axis name array or NULL. */
const char **axis_names; /* Axis name array or NULL. */
};