On 2/20/22 20:44, Alec Ari via Emc-developers wrote:
I would submit pull requests on Github. Basically, fork LinuxCNC, make a commit 
to your fork, then there's a button for make pull request:

https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github

Adding Clang support in LinuxCNC may be a way to detect previously undiscovered 
potential problems in the code base. Any errors or just warnings? The runtests 
may have failed because you weren't running a real-time kernel, not sure.

Alec

Thanks. I figured out the forking. Clang only gave warnings. Most of the warning were 'spurious'. For example 'if' indentation being misleading.

There was one where a member variable that was not being set in the constructor. Fixed that.

There are some I didn't fix because I don't know the code. For example:

emc/rs274ngc/interp_write.cc:165:19: warning: address of array 'settings->speed_override' will always evaluate to 'true' [-Wpointer-bool-conversion]
    if (settings->speed_override) emz[6] =  48;
    ~~  ~~~~~~~~~~^~~~~~~~~~~~~~
emc/rs274ngc/interp_write.cc:167:24: warning: address of array 'settings->speed_override' will always evaluate to 'true' [-Wpointer-bool-conversion]
  } else if (settings->speed_override) {
         ~~  ~~~~~~~~~~^~~~~~~~~~~~~~
emc/rs274ngc/interp_write.cc:318:53: warning: address of array 'settings->speed_override' will always evaluate to 'true' [-Wpointer-bool-conversion]
    state.flags[GM_FLAG_SPEED_OVERRIDE] = settings->speed_override;
                                        ~ ~~~~~~~~~~^~~~~~~~~~~~~~

The code in question is:

  if (settings->feed_override) {
    if (settings->speed_override) emz[6] =  48;
    else emz[6] = 50;
  } else if (settings->speed_override) {
    emz[6] = 51;
  } else emz[6] = 49;

speed_override is actually an array of bools, one for each spindle.

 bool speed_override[EMCMOT_MAX_SPINDLES];        // whether speed override is enabled

That bit looks broken to me. There is another function that gets the speed_override.

static inline bool get_speed_override (Interp &interp)  {
    return interp._setup.speed_override;

}

My guess is that speed_override was once a single bool, and later changed to array to support multiple spindles.


In terms of support, all I did was set CXX, CC, CPP

CPP=clang-cpp-13
CXX=clang++-13
CC=clang-13

Then I re-ran configure, ignoring gtk2.

./configure --disable-gtk2 --with-realtime=uspace

I've got one branch with the clang changes. I working on another that addresses gcc warnings.

Regards, Andy



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


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

Reply via email to