From 188652f9cfe7866745f2492f4b3aee5bc930c155 Mon Sep 17 00:00:00 2001 From: Steffen Moeller Date: Sun, 1 Feb 2026 17:53:38 +0000 Subject: [PATCH 1/2] libnml,emc: strtok -> strtok_r --- src/emc/rs274ngc/interp_remap.cc | 5 +++-- src/emc/rs274ngc/rs274ngc_pre.cc | 5 +++-- src/emc/task/emctask.cc | 5 +++-- src/emc/tooldata/tooldata_common.cc | 9 +++++---- src/emc/tooldata/tooldata_db.cc | 5 +++-- src/libnml/rcs/rcs_print.cc | 5 +++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/emc/rs274ngc/interp_remap.cc b/src/emc/rs274ngc/interp_remap.cc index 34ae760830c..2677639b155 100644 --- a/src/emc/rs274ngc/interp_remap.cc +++ b/src/emc/rs274ngc/interp_remap.cc @@ -368,11 +368,12 @@ int Interp::parse_remap(const char *inistring, int lineno) if ((s = strchr(iniline, '#')) != NULL) { *s = '\0'; } - s = strtok((char *) iniline, " \t"); + char* saveptr; + s = strtok_r((char *) iniline, " \t", &saveptr); while( s != NULL && argc < MAX_REMAPOPTS - 1) { argv[argc++] = s; - s = strtok( NULL, " \t" ); + s = strtok_r( NULL, " \t", &saveptr); } if (argc == MAX_REMAPOPTS) { Error("parse_remap: too many arguments (max %d)", MAX_REMAPOPTS); diff --git a/src/emc/rs274ngc/rs274ngc_pre.cc b/src/emc/rs274ngc/rs274ngc_pre.cc index 1aceefb932e..f51bc682a95 100644 --- a/src/emc/rs274ngc/rs274ngc_pre.cc +++ b/src/emc/rs274ngc/rs274ngc_pre.cc @@ -975,7 +975,8 @@ int Interp::init() } rtapi_strxcpy(tmpdirs,inistring); - nextdir = strtok(tmpdirs,":"); // first token + char *saveptr; + nextdir = strtok_r(tmpdirs,":",&saveptr); // first token dct = 0; while (1) { char tmp_path[PATH_MAX]; @@ -996,7 +997,7 @@ int Interp::init() logDebug("too many entries in SUBROUTINE_PATH, max=%d", MAX_SUB_DIRS); break; } - nextdir = strtok(NULL,":"); + nextdir = strtok_r(NULL,":",&saveptr); if (nextdir == NULL) break; // no more tokens } } diff --git a/src/emc/task/emctask.cc b/src/emc/task/emctask.cc index 5d84a42f9c4..ef96ceb4de2 100644 --- a/src/emc/task/emctask.cc +++ b/src/emc/task/emctask.cc @@ -147,7 +147,8 @@ int emcTaskInit() } strncpy(tmpdirs, inistring, sizeof(tmpdirs)); - nextdir = strtok(tmpdirs,":"); // first token + char* saveptr; + nextdir = strtok_r(tmpdirs,":", &saveptr); // first token dct = 1; while (dct < MAX_M_DIRS) { if (nextdir == NULL) break; // no more tokens @@ -157,7 +158,7 @@ int emcTaskInit() return -1; } strncpy(mdir[dct], nextdir, sizeof(mdir[dct])); - nextdir = strtok(NULL,":"); + nextdir = strtok_r(NULL,":",&saveptr); dct++; } dmax=dct; diff --git a/src/emc/tooldata/tooldata_common.cc b/src/emc/tooldata/tooldata_common.cc index 9c2a9f7e224..8042d3900b9 100644 --- a/src/emc/tooldata/tooldata_common.cc +++ b/src/emc/tooldata/tooldata_common.cc @@ -93,14 +93,15 @@ int tooldata_read_entry(const char *input_line, orientation = empty.orientation; offset = empty.offset; - buff = strtok(work_line, ";"); + char* saveptr; + buff = strtok_r(work_line, ";", &saveptr); if (strlen(buff) <=1) { //fprintf(stderr,"skip blankline %s\n",__FILE__); return 0; } - comment = strtok(NULL, "\n"); + comment = strtok_r(NULL, "\n", &saveptr); - token = strtok(buff, " "); + token = strtok_r(buff, " ", &saveptr); while (token != NULL) { switch (toupper(token[0])) { case 'T': @@ -188,7 +189,7 @@ int tooldata_read_entry(const char *input_line, valid = 0; break; } - token = strtok(NULL, " "); + token = strtok_r(NULL, " ", &saveptr); } // while token if (valid) { diff --git a/src/emc/tooldata/tooldata_db.cc b/src/emc/tooldata/tooldata_db.cc index 4496ee2573f..25edbec18f4 100644 --- a/src/emc/tooldata/tooldata_db.cc +++ b/src/emc/tooldata/tooldata_db.cc @@ -242,7 +242,8 @@ int tooldata_db_init(char progname_plus_args[],int random_toolchanger) if (getenv( (char*)"DB_SHOW") ) {db_show = 1;} int child_argc = 0; char* child_argv[MAX_DB_PROGRAM_ARGS] = {0}; - char* token = strtok(progname_plus_args, " "); + char* saveptr; + char* token = strtok_r(progname_plus_args, " ", &saveptr); while (token != NULL) { child_argv[child_argc] = token; child_argc++; @@ -251,7 +252,7 @@ int tooldata_db_init(char progname_plus_args[],int random_toolchanger) ,MAX_DB_PROGRAM_ARGS); return -1; } - token = strtok(NULL, " "); + token = strtok_r(NULL, " ", &saveptr); } snprintf(db_childname,sizeof(db_childname),"%s",child_argv[0]); is_random_toolchanger = random_toolchanger; diff --git a/src/libnml/rcs/rcs_print.cc b/src/libnml/rcs/rcs_print.cc index 4687921654b..bc63b7f3ddc 100644 --- a/src/libnml/rcs/rcs_print.cc +++ b/src/libnml/rcs/rcs_print.cc @@ -275,9 +275,10 @@ int separate_words(char **_dest, int _max, char *_src) return -1; } rtapi_strxcpy(word_buffer, _src); - _dest[0] = strtok(word_buffer, " \n\r\t"); + char* saveptr; + _dest[0] = strtok_r(word_buffer, " \n\r\t", &saveptr); for (i = 0; NULL != _dest[i] && i < _max - 1; i++) { - _dest[i + 1] = strtok(NULL, " \n\r\t"); + _dest[i + 1] = strtok_r(NULL, " \n\r\t", &saveptr); } if (_dest[_max - 1] == NULL && i == _max - 1) { i--; From 9572373ce0515c5dc1b2e71076d878604b0a22a6 Mon Sep 17 00:00:00 2001 From: Steffen Moeller Date: Sun, 1 Feb 2026 22:47:28 +0000 Subject: [PATCH 2/2] github/ci: retry apt-get 5 times prior to error --- .github/workflows/ci.yml | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e356664d225..4546c32ab32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,9 +30,9 @@ jobs: - name: Build RIP & test run: | set -x - sudo apt-get install -y eatmydata + sudo apt-get --yes -o Acquire::Retries=5 install eatmydata eatmydata ./scripts/travis-install-build-deps.sh - sudo eatmydata apt --quiet --yes upgrade + sudo eatmydata apt --yes --quiet -o Acquire::Retries=5 upgrade cd src eatmydata ./autogen.sh eatmydata ./configure --with-realtime=uspace --disable-check-runtime-deps @@ -55,10 +55,10 @@ jobs: - name: Clang build RIP & test run: | set -x - sudo apt-get install -y eatmydata + sudo apt-get --yes -o Acquire::Retries=5 install eatmydata eatmydata ./scripts/travis-install-build-deps.sh - sudo eatmydata apt-get install -y clang - sudo eatmydata apt --quiet --yes upgrade + sudo eatmydata apt-get -y -o Acquire::Retries=5 install clang + sudo eatmydata apt --yes --quiet -o Acquire::Retries=5 upgrade cd src eatmydata ./autogen.sh CC=clang CXX=clang++ eatmydata ./configure --with-realtime=uspace --disable-check-runtime-deps @@ -81,8 +81,8 @@ jobs: - name: Build HTML docmentation run: | ./scripts/travis-install-build-deps.sh - sudo apt-get install -y eatmydata - sudo eatmydata apt --quiet --yes upgrade + sudo apt-get -y -o Acquire::Retries=5 install eatmydata + sudo eatmydata apt --yes --quiet -o Acquire::Retries=5 upgrade cd src eatmydata ./autogen.sh eatmydata ./configure --with-realtime=uspace --disable-check-runtime-deps --enable-build-documentation=html @@ -113,11 +113,11 @@ jobs: run: | set -e set -x - apt-get --quiet update - apt-get --yes --quiet install eatmydata curl - eatmydata apt --quiet --yes upgrade + apt-get --quiet -o Acquire::Retries=5 update + apt-get --yes --quiet -o Acquire::Retries=5 install eatmydata curl + eatmydata apt --yes --quiet -o Acquire::Retries=5 upgrade # Install stuff needed to check out the linuxcnc repo and turn it into a debian source package. - eatmydata apt-get --yes --quiet install --no-install-suggests git lsb-release python3 devscripts + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 install --no-install-suggests git lsb-release python3 devscripts - uses: actions/checkout@v3 with: @@ -138,11 +138,11 @@ jobs: esac set -e set -x - eatmydata apt-get --yes --quiet install --no-install-recommends gpg software-properties-common + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 install --no-install-recommends gpg software-properties-common eatmydata gpg --homedir="${PWD}/gnupg" --output /etc/apt/trusted.gpg.d/linuxcnc-deb-archive.gpg --export 3CB9FD148F374FEF DIST=$(echo ${{matrix.image}} | cut -d : -f 2) eatmydata add-apt-repository "deb http://linuxcnc.org $DIST base" - eatmydata apt-get --quiet update + eatmydata apt-get --quiet -o Acquire::Retries=5 update - name: Build architecture-specific Debian packages env: @@ -157,7 +157,7 @@ jobs: eatmydata debian/update-dch-from-git eatmydata scripts/get-version-from-git | sed -re 's/^v(.*)$/\1/' >| VERSION; cat VERSION eatmydata git diff - eatmydata apt-get --yes --quiet build-dep --arch-only . + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 build-dep --arch-only . eatmydata debuild -us -uc --build=any - name: Test debian packages env: @@ -165,8 +165,8 @@ jobs: run: | set -e set -x - eatmydata apt-get --yes --quiet install ../*.deb - eatmydata apt-get --yes --quiet install sudo # some tests run sudo... + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 install ../*.deb + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 install sudo # some tests run sudo... eatmydata adduser --disabled-password --gecos "" testrunner eatmydata passwd -d testrunner eatmydata adduser testrunner sudo @@ -220,11 +220,11 @@ jobs: run: | set -e set -x - apt-get --quiet update - apt-get --yes --quiet install eatmydata curl - eatmydata apt --quiet --yes upgrade + apt-get --quiet -o Acquire::Retries=5 update + apt-get --yes --quiet -o Acquire::Retries=5 install eatmydata curl + eatmydata apt --yes --quiet -o Acquire::Retries=5 upgrade # Install stuff needed to check out the linuxcnc repo and turn it into a debian source package. - eatmydata apt-get --yes --quiet install --no-install-suggests git lsb-release python3 devscripts + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 install --no-install-suggests git lsb-release python3 devscripts - uses: actions/checkout@v3 with: @@ -245,11 +245,11 @@ jobs: esac set -e set -x - eatmydata apt-get --yes --quiet install gpg software-properties-common + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 install gpg software-properties-common eatmydata gpg --homedir="${PWD}/gnupg" --output /etc/apt/trusted.gpg.d/linuxcnc-deb-archive.gpg --export 3CB9FD148F374FEF DIST=$(echo ${{matrix.image}} | cut -d : -f 2) eatmydata add-apt-repository "deb http://linuxcnc.org $DIST base" - eatmydata apt-get --quiet update + eatmydata apt-get --quiet -o Acquire::Retries=5 update - name: Build architecture-independent Debian packages env: @@ -264,7 +264,7 @@ jobs: eatmydata debian/update-dch-from-git eatmydata scripts/get-version-from-git | sed -re 's/^v(.*)$/\1/' >| VERSION; cat VERSION eatmydata git diff - eatmydata apt-get --yes --quiet build-dep --indep-only . + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 build-dep --indep-only . eatmydata debuild -us -uc --build=all - name: Test install debian packages env: @@ -272,7 +272,7 @@ jobs: run: | set -e set -x - eatmydata apt-get --yes --quiet install ../*.deb + eatmydata apt-get --yes --quiet -o Acquire::Retries=5 install ../*.deb - name: Gather build artifacts run: | set -e @@ -311,7 +311,7 @@ jobs: run: | set -x git fetch --recurse-submodules=no https://github.com/linuxcnc/linuxcnc refs/tags/*:refs/tags/* - sudo apt-get -y install cppcheck shellcheck + sudo apt-get --yes -o Acquire::Retries=5 install cppcheck shellcheck scripts/cppcheck.sh - name: Shellcheck continue-on-error: true