]> git.feebdaed.xyz Git - 0xmirror/CANopenLinux.git/commitdiff
Fix example/CO_storageLinux.c.
authorJanez <janez.paternoster@siol.net>
Thu, 10 Oct 2024 14:12:04 +0000 (16:12 +0200)
committerJanez <janez.paternoster@siol.net>
Thu, 10 Oct 2024 14:12:04 +0000 (16:12 +0200)
CO_LOCK_OD(CANmodule) must not be used, because lock is already
applied by SDO server.

CANopenNode
CO_storageLinux.c

index 05931a6b763299cc1bff2eb8c6926f086bc55131..29c5b64131654b6f6f2171c64a1d5ce8031bcaa0 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 05931a6b763299cc1bff2eb8c6926f086bc55131
+Subproject commit 29c5b64131654b6f6f2171c64a1d5ce8031bcaa0
index 406d7e36ebb78a8b2ff99047f3b19f88c682c812..4d8a5b22dab0837eaae790bdabffed622f1922e8 100644 (file)
@@ -33,6 +33,7 @@
  */
 static ODR_t
 storeLinux(CO_storage_entry_t* entry, CO_CANmodule_t* CANmodule) {
+    (void)CANmodule;
     ODR_t ret = ODR_OK;
     uint16_t crc_store;
 
@@ -61,10 +62,10 @@ storeLinux(CO_storage_entry_t* entry, CO_CANmodule_t* CANmodule) {
         if (fp == NULL) {
             ret = ODR_HW;
         } else {
-            CO_LOCK_OD(CANmodule);
+            /* following two lines are subject to race conditions. This function is called only by SDO server
+             * and so it is already protected by CO_LOCK_OD. */
             size_t cnt = fwrite(entry->addr, 1, entry->len, fp);
             crc_store = crc16_ccitt(entry->addr, entry->len, 0);
-            CO_UNLOCK_OD(CANmodule);
             cnt += fwrite(&crc_store, 1, sizeof(crc_store), fp);
             fclose(fp);
             if (cnt != (entry->len + sizeof(crc_store))) {