diff --git a/SOEM-1.4.0.tar.gz b/SOEM-1.4.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..93555e087013d543e74f94d45c26e4b3797da245 Binary files /dev/null and b/SOEM-1.4.0.tar.gz differ diff --git a/fix-warning-with-strncpy-on-newer-GCC-versions.patch b/fix-warning-with-strncpy-on-newer-GCC-versions.patch new file mode 100644 index 0000000000000000000000000000000000000000..09b5f8178a35ad0f4e4116d2508f131d47c7b582 --- /dev/null +++ b/fix-warning-with-strncpy-on-newer-GCC-versions.patch @@ -0,0 +1,171 @@ +From cffd3ba283dcbfc9f44c0d4d45a169e1583fb726 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Juanjo=20Guti=C3=A9rrez?= +Date: Fri, 18 Oct 2019 13:19:21 +0200 +Subject: [PATCH] fix warning with strncpy on newer GCC versions + +strncpy should not be called with a "length" parameter which is based on +the source string since it negates the benefits of using strncpy. this +patch fixes the warning for linux, macosx and rtems + +Fixes #346 +Change-Id: Ib2fb7637e9845545e4c15045e6be7c7ce8e0672b +--- + oshw/linux/oshw.c | 14 ++++---------- + oshw/macosx/oshw.c | 16 +++++----------- + oshw/rtems/oshw.c | 16 +++++----------- + oshw/win32/oshw.c | 19 ++++--------------- + 4 files changed, 18 insertions(+), 47 deletions(-) + +diff --git a/oshw/linux/oshw.c b/oshw/linux/oshw.c +index 4526dfa..23f6f19 100644 +--- a/oshw/linux/oshw.c ++++ b/oshw/linux/oshw.c +@@ -42,7 +42,6 @@ uint16 oshw_ntohs(uint16 network) + ec_adaptert * oshw_find_adapters(void) + { + int i; +- int string_len; + struct if_nameindex *ids; + ec_adaptert * adapter; + ec_adaptert * prev_adapter; +@@ -75,15 +74,10 @@ ec_adaptert * oshw_find_adapters(void) + + if (ids[i].if_name) + { +- string_len = strlen(ids[i].if_name); +- if (string_len > (EC_MAXLEN_ADAPTERNAME - 1)) +- { +- string_len = EC_MAXLEN_ADAPTERNAME - 1; +- } +- strncpy(adapter->name, ids[i].if_name,string_len); +- adapter->name[string_len] = '\0'; +- strncpy(adapter->desc, ids[i].if_name,string_len); +- adapter->desc[string_len] = '\0'; ++ strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); ++ adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0'; ++ strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); ++ adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0'; + } + else + { +diff --git a/oshw/macosx/oshw.c b/oshw/macosx/oshw.c +index 4526dfa..90406ad 100644 +--- a/oshw/macosx/oshw.c ++++ b/oshw/macosx/oshw.c +@@ -42,7 +42,6 @@ uint16 oshw_ntohs(uint16 network) + ec_adaptert * oshw_find_adapters(void) + { + int i; +- int string_len; + struct if_nameindex *ids; + ec_adaptert * adapter; + ec_adaptert * prev_adapter; +@@ -70,20 +69,15 @@ ec_adaptert * oshw_find_adapters(void) + ret_adapter = adapter; + } + +- /* fetch description and name, in Linux we use the same on both */ ++ /* fetch description and name, in macosx we use the same on both */ + adapter->next = NULL; + + if (ids[i].if_name) + { +- string_len = strlen(ids[i].if_name); +- if (string_len > (EC_MAXLEN_ADAPTERNAME - 1)) +- { +- string_len = EC_MAXLEN_ADAPTERNAME - 1; +- } +- strncpy(adapter->name, ids[i].if_name,string_len); +- adapter->name[string_len] = '\0'; +- strncpy(adapter->desc, ids[i].if_name,string_len); +- adapter->desc[string_len] = '\0'; ++ strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); ++ adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0'; ++ strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); ++ adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0'; + } + else + { +diff --git a/oshw/rtems/oshw.c b/oshw/rtems/oshw.c +index 4526dfa..f807570 100644 +--- a/oshw/rtems/oshw.c ++++ b/oshw/rtems/oshw.c +@@ -42,7 +42,6 @@ uint16 oshw_ntohs(uint16 network) + ec_adaptert * oshw_find_adapters(void) + { + int i; +- int string_len; + struct if_nameindex *ids; + ec_adaptert * adapter; + ec_adaptert * prev_adapter; +@@ -70,20 +69,15 @@ ec_adaptert * oshw_find_adapters(void) + ret_adapter = adapter; + } + +- /* fetch description and name, in Linux we use the same on both */ ++ /* fetch description and name, in rtems we use the same on both */ + adapter->next = NULL; + + if (ids[i].if_name) + { +- string_len = strlen(ids[i].if_name); +- if (string_len > (EC_MAXLEN_ADAPTERNAME - 1)) +- { +- string_len = EC_MAXLEN_ADAPTERNAME - 1; +- } +- strncpy(adapter->name, ids[i].if_name,string_len); +- adapter->name[string_len] = '\0'; +- strncpy(adapter->desc, ids[i].if_name,string_len); +- adapter->desc[string_len] = '\0'; ++ strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); ++ adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0'; ++ strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); ++ adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0'; + } + else + { +diff --git a/oshw/win32/oshw.c b/oshw/win32/oshw.c +index e58f5fa..c217baa 100644 +--- a/oshw/win32/oshw.c ++++ b/oshw/win32/oshw.c +@@ -42,7 +42,6 @@ ec_adaptert * oshw_find_adapters (void) + ec_adaptert * prev_adapter; + ec_adaptert * ret_adapter = NULL; + char errbuf[PCAP_ERRBUF_SIZE]; +- size_t string_len; + + /* find all devices */ + if (pcap_findalldevs(&alldevs, errbuf) == -1) +@@ -73,13 +72,8 @@ ec_adaptert * oshw_find_adapters (void) + adapter->next = NULL; + if (d->name) + { +- string_len = strlen(d->name); +- if (string_len > (EC_MAXLEN_ADAPTERNAME - 1)) +- { +- string_len = EC_MAXLEN_ADAPTERNAME - 1; +- } +- strncpy(adapter->name, d->name,string_len); +- adapter->name[string_len] = '\0'; ++ strncpy(adapter->name, d->name, EC_MAXLEN_ADAPTERNAME); ++ adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0'; + } + else + { +@@ -87,13 +81,8 @@ ec_adaptert * oshw_find_adapters (void) + } + if (d->description) + { +- string_len = strlen(d->description); +- if (string_len > (EC_MAXLEN_ADAPTERNAME - 1)) +- { +- string_len = EC_MAXLEN_ADAPTERNAME - 1; +- } +- strncpy(adapter->desc, d->description,string_len); +- adapter->desc[string_len] = '\0'; ++ strncpy(adapter->desc, d->description, EC_MAXLEN_ADAPTERNAME); ++ adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0'; + } + else + { + diff --git a/soem.spec b/soem.spec new file mode 100644 index 0000000000000000000000000000000000000000..f5c8cc8cf6c3dcd93e2aa204d31aab5bc393d652 --- /dev/null +++ b/soem.spec @@ -0,0 +1,44 @@ +Name: soem +Version: 1.4.0 +Release: 1 +Summary: Simple Open EtherCAT Master Library +License: GPL-2.0-only +URL: https://github.com/OpenEtherCATsociety/SOEM +Source0: https://github.com/OpenEtherCATsociety/SOEM/archive/v%{version}/SOEM-%{version}.tar.gz +Patch0: fix-warning-with-strncpy-on-newer-GCC-versions.patch + +BuildRequires: gcc make cmake + +%description +SOEM is an EtherCAT master library written in c. Its purpose is to learn and to use. All users are invited to study the source to get an understanding how an EtherCAT master functions and how it interacts with EtherCAT slaves. + +%package devel +Summary: Development files for SOEM +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +Development files for SOEM + +%prep +%autosetup -n SOEM-%{version} -p1 +# set libsoem.a in lib or lib64 +sed -i 's/set(SOEM_LIB_INSTALL_DIR lib)/set(SOEM_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})/g' CMakeLists.txt + +%build +%cmake -DCMAKE_INSTALL_LIBDIR=%{_lib} +%make_build + +%install +%make_install + +%files +%license LICENSE +%{_bindir}/* + +%files devel +%{_includedir}/soem/* +%{_libdir}/*.a + +%changelog +* Thu Apr 18 2024 TianyuWang - 1.4.0-1 +- Initial package \ No newline at end of file diff --git a/soem.yaml b/soem.yaml new file mode 100644 index 0000000000000000000000000000000000000000..939988c360295e61ac2749115f98941b6a2403fd --- /dev/null +++ b/soem.yaml @@ -0,0 +1,5 @@ +git_url: https://github.com/OpenEtherCATsociety/SOEM.git +version_control: github +src_repo: OpenEtherCATsociety/SOEM +tag_prefix: "SOEM-" +separator: "." \ No newline at end of file