Compiling LinuxCNC at the moment gives an awful lot of warnings.

Many of them relate to packing (potentially) too many characters in to
HAL pin names with snprintf.

Example:

hal/user_comps/mb2hal/mb2hal_hal.c:38:5: note: ‘snprintf’ output 13 or
more bytes (assuming 60) into a destination of size 47

     snprintf(hal_pin_name, HAL_NAME_LEN, "%s.%s.num_errors",
gbl.hal_mod_name, mb_tx->hal_tx_name);

It isn't wrong,
https://github.com/LinuxCNC/linuxcnc/blob/master/src/hal/hal.h#L139
#define HAL_NAME_LEN 47 /* length for pin, signal, etc, names */

And
https://github.com/LinuxCNC/linuxcnc/blob/0f91c553a238c3f5e8a52285044761c2dcfd7de5/src/hal/user_comps/mb2hal/mb2hal_init.c#L92
tag = "HAL_MODULE_NAME"; //optional
tmpstr = iniFind(gbl.ini_file_ptr, tag, section);
if (tmpstr != NULL) {
gbl.hal_mod_name = strdup(tmpstr);
}

Currently these are just warnings, but I can see that there could be
real problems with duplicated pin names in some circumstances.

Is it worth trying to fix this? One answer might be to define a
hal_snprintf function that returns an error at runtime if the pin name
won't fit.
I didn't pick on mb2hal for any reason other than it is early in the
compile sequence, but it is a good example as it picks a string of
unbound length from the INI file.

[MB2HAL]
HAL_MODULE_NAME = A_ridiculoiusly_long_name_to_make_all_hal_pins_the_same_name

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to