From 4d9da268be1ca5c810aaf838786924d0c21a15d3 Mon Sep 17 00:00:00 2001 From: Hans-Erik Floryd Date: Mon, 25 Oct 2021 09:50:57 +0200 Subject: [PATCH 1/3] Bump build platform Ubuntu 16.04 is now deprecated. Build using latest LTS. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3062cca..88abc3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ env: BUILD_TYPE: Release jobs: build: - runs-on: ubuntu-16.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 with: From 097477035d768beafce5a2b4d8742a1b7bea9a29 Mon Sep 17 00:00:00 2001 From: Hans-Erik Floryd Date: Mon, 25 Oct 2021 13:33:01 +0200 Subject: [PATCH 2/3] Fix address-of-packed-member warnings GCC9 introduced an address-of-packed-member warning that triggers in esc_coe.c. The issue is that a packed struct has an overall alignment of 1, and taking the address of a member in a packed struct is not guaranteed to have any particular alignment. However, in esc_coe these structs are always overlayed on aligned memory so in practice there is no problem. Fix the problem by explicitly setting the minimum alignment for the structs used in this manner. Also fix an instance where an unaligned pointer was used but never dereferenced (by changing the type of the pointer from uint32_t* to void*). --- soes/esc.h | 4 ++-- soes/esc_coe.c | 4 ++-- soes/include/sys/gcc/cc.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/soes/esc.h b/soes/esc.h index f6f4535..d3beed0 100644 --- a/soes/esc.h +++ b/soes/esc.h @@ -573,7 +573,7 @@ typedef struct CC_PACKED CC_PACKED_END CC_PACKED_BEGIN -typedef struct CC_PACKED +typedef struct CC_PACKED CC_ALIGNED(4) { _MBXh mbxheader; _COEh coeheader; @@ -585,7 +585,7 @@ typedef struct CC_PACKED CC_PACKED_END CC_PACKED_BEGIN -typedef struct CC_PACKED +typedef struct CC_PACKED CC_ALIGNED(4) { _MBXh mbxheader; _COEh coeheader; diff --git a/soes/esc_coe.c b/soes/esc_coe.c index 14b832a..851f8e1 100644 --- a/soes/esc_coe.c +++ b/soes/esc_coe.c @@ -1022,8 +1022,8 @@ static void SDO_downloadsegment (void) (coesdo->command & COE_TOGGLEBIT); /* copy toggle bit */ init_coesdo(coeres, COE_SDORESPONSE, command, 0, 0); - uint32_t *mbxdata = (uint32_t *)&(coesdo->index); /* data pointer */ - copy2mbx (mbxdata, (uint8_t *)ESCvar.data, size); + void *mbxdata = &(coesdo->index); /* data pointer */ + copy2mbx (mbxdata, ESCvar.data, size); if (coesdo->command & COE_COMMAND_LASTSEGMENTBIT) { diff --git a/soes/include/sys/gcc/cc.h b/soes/include/sys/gcc/cc.h index b3067b0..c4598bd 100644 --- a/soes/include/sys/gcc/cc.h +++ b/soes/include/sys/gcc/cc.h @@ -32,6 +32,7 @@ extern "C" #define CC_PACKED_BEGIN #define CC_PACKED_END #define CC_PACKED __attribute__((packed)) +#define CC_ALIGNED(n) __attribute__((aligned (n))) #ifdef __rtk__ #define CC_ASSERT(exp) ASSERT (exp) From 2808e956688805549e9f513a15fd559962261e18 Mon Sep 17 00:00:00 2001 From: Hans-Erik Floryd Date: Mon, 25 Oct 2021 13:39:07 +0200 Subject: [PATCH 3/3] Bump cmake version Specifying a minimum cmake version 0f 2.8.4 triggers a warning with never cmake, due to backwards compatibility issue. Bump to 2.8.12 which is the oldest version without the warning. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b397193..576979e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists files in this project can # refer to the root source directory of the project as ${SOES_SOURCE_DIR} and # to the root binary directory of the project as ${SOES_BINARY_DIR}. -cmake_minimum_required (VERSION 2.8.4) +cmake_minimum_required (VERSION 2.8.12) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") project (SOES)