plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Tue, 14 Jan 2020 11:04:18 +0100
changeset 2710 aaa1dc426213
parent 2709 a1b185e21295
child 2711 ecfb59e4ecb0
plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
targets/plc_debug.c
targets/var_access.c
--- a/targets/plc_debug.c	Fri Jul 03 14:02:04 2020 +0200
+++ b/targets/plc_debug.c	Tue Jan 14 11:04:18 2020 +0100
@@ -100,7 +100,7 @@
 void __init_debug(void)
 {
     /* init local static vars */
-#ifndef TARGET_ONLINE_DEBUG_DISABLE	
+#ifndef TARGET_ONLINE_DEBUG_DISABLE
     buffer_cursor = debug_buffer;
     buffer_state = BUFFER_FREE;
 #endif
@@ -109,9 +109,9 @@
     InitRetain();
     /* Iterate over all variables to fill debug buffer */
     if(CheckRetainBuffer()){
-    	__for_each_variable_do(RemindIterator);
+        __for_each_variable_do(RemindIterator);
     }else{
-    	char mstr[] = "RETAIN memory invalid - defaults used";
+        char mstr[] = "RETAIN memory invalid - defaults used";
         LogMessage(LOG_WARNING, mstr, sizeof(mstr));
     }
     retain_offset = 0;
@@ -124,7 +124,7 @@
 
 void __cleanup_debug(void)
 {
-#ifndef TARGET_ONLINE_DEBUG_DISABLE	
+#ifndef TARGET_ONLINE_DEBUG_DISABLE
     buffer_cursor = debug_buffer;
     InitiateDebugTransfer();
 #endif    
@@ -150,16 +150,14 @@
     if(flags & ( __IEC_DEBUG_FLAG | __IEC_RETAIN_FLAG)){
         USINT size = __get_type_enum_size(dsc->type);
 
-#ifndef TARGET_ONLINE_DEBUG_DISABLE	
+#ifndef TARGET_ONLINE_DEBUG_DISABLE
         if(flags & __IEC_DEBUG_FLAG){
             /* copy visible variable to buffer */;
             if(do_debug){
                 /* compute next cursor positon.
                    No need to check overflow, as BUFFER_SIZE
                    is computed large enough */
-		if((dsc->type == STRING_ENUM)   ||
-		   (dsc->type == STRING_P_ENUM) ||
-		   (dsc->type == STRING_O_ENUM)){
+                if(__Is_a_string(dsc)){
                     /* optimization for strings */
                     size = ((STRING*)visible_value_p)->len + 1;
                 }
@@ -174,7 +172,7 @@
                 memcpy(real_value_p, visible_value_p, size);
             }
         }
-#endif	
+#endif
 
         if(flags & __IEC_RETAIN_FLAG){
             /* compute next cursor positon*/
--- a/targets/var_access.c	Fri Jul 03 14:02:04 2020 +0200
+++ b/targets/var_access.c	Tue Jan 14 11:04:18 2020 +0100
@@ -14,6 +14,10 @@
             forced_value_p = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\
             break;
 
+#define __Is_a_string(dsc) (dsc->type == STRING_ENUM)   ||\
+                           (dsc->type == STRING_P_ENUM) ||\
+                           (dsc->type == STRING_O_ENUM)
+
 static void* UnpackVar(__Unpack_desc_type *dsc, void **real_value_p, char *flags)
 {
     void *varp = dsc->ptr;