LinuxCNC / linuxcnc

LinuxCNC controls CNC machines. It can drive milling machines, lathes, 3d printers, laser cutters, plasma cutters, robot arms, hexapods, and more.
http://linuxcnc.org/
GNU General Public License v2.0
1.78k stars 1.15k forks source link

Refactor count_names() for improved clarity #2788

Closed havardAasen closed 9 months ago

havardAasen commented 9 months ago

Simplified the logic by changing to a while loop and removing a variable.

andypugh commented 9 months ago

I think that your code continues an error in the existing code, that the limit may not be MAX_IO for all cases where the function is called. This isn't currrently a problem. https://github.com/LinuxCNC/linuxcnc/blob/2.9/src/emc/motion/emcmotcfg.h#L33 But it feels like the function should be passed the relevant parameter rather than the local MAX_IO.

havardAasen commented 9 months ago

I think that your code continues an error in the existing code, that the limit may not be MAX_IO for all cases where the function is called. This isn't currrently a problem. https://github.com/LinuxCNC/linuxcnc/blob/2.9/src/emc/motion/emcmotcfg.h#L33 https://github.com/LinuxCNC/linuxcnc/blob/2.9/src/emc/motion/emcmotcfg.h#L33 But it feels like the function should be passed the relevant parameter rather than the local MAX_IO.

Yes, I agree. Then we can remove MAX_IO and rather use EMCMOT_MAX_* when we define the arrays, and send the macro in as a max_len parameter.