On Sunday 22 March 2020 07:32:25 andy pugh wrote:

> 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.
>
I've been noting that myself for years any, Andy, but shouldn't runtests 
check for such?

There are, and have been for years as I built master from scratch quite a 
few times over at least 10 years, first time was
 was 2.4 IIRC. If the environment was kosher, those errors are the only 
errors in the whole process of making installable debs and they pass 
last weeks runtests and run just time.

> 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/0f91c553a238c3f5e8a522850447
>61c2dcfd7de5/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.

That could be the best solution, provided it was noisy enough to I.D. the 
source code line that triggered it. That might be quite difficult if not 
impossible to do.

> 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


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>


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

Reply via email to