Skip to contentSkip to conversation

envcommon

PATCH New Robert Schwebel 2 participants 2 messages May 13, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 envcommon

ChangeLog:

* Patch by Kai-Uwe Bloem, Robert Schwebel, 13 May 2004:
Copy data only when we _have_ a default environment, otherwhise set environment to 0.

Robert

Signature · 40 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hornemannstra?e 12,  31137 Hildesheim, Germany
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
-------------- next part --------------
# 
# Author:	Robert Schwebel <[email protected]>
# 
# Description:	ChangeLog: 
#
#		* Patch by Kai-Uwe Bloem, Robert Schwebel, 13 May 2004:
#		  Copy data only when we _have_ a default environment,
#		  otherwhise set environment to 0. 
#
# State:	2004-05-13: submit
#

#
# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
#

--- u-boot-patches/common/env_common.c~envcommon	2003-07-24 16:59:26.000000000 +0200
+++ u-boot-patches/common/env_common.c	2003-12-09 08:52:26.000000000 +0100
@@ -242,9 +242,12 @@
 		}
 
 		memset (env_ptr, 0, sizeof(env_t));
-		memcpy (env_ptr->data,
-			default_environment,
-			sizeof(default_environment));
+		if (sizeof(default_environment) > 0)
+			memcpy (env_ptr->data,
+				default_environment,
+				sizeof(default_environment));
+		else
+			env_ptr->data[0] = '\0';
 #ifdef CFG_REDUNDAND_ENVIRONMENT
 		env_ptr->flags = 0xFF;
 #endif
#1 lore raw

PATCH 1/1 envcommon

Quoted 4 lines · In message <[email protected]> you wrote:

* Patch by Kai-Uwe Bloem, Robert Schwebel, 13 May 2004:
Copy data only when we _have_ a default environment, otherwhise set environment to 0.

Why is this patch needed?

Quoted 1 line

memset (env_ptr, 0, sizeof(env_t));

Here the environment gets zeroed.

Review

Quoted 9 lines
(quoted diff) +6 -3
-		memcpy (env_ptr->data,
-			default_environment,
-			sizeof(default_environment));
+		if (sizeof(default_environment) > 0)
+			memcpy (env_ptr->data,
+				default_environment,
+				sizeof(default_environment));
+		else
+			env_ptr->data[0] = '\0';

For sizeof(default_environment)>0 your patch does not change anything; for sizeof(default_environment)==0 it adds the "env_ptr->data[0] = '\0'" statement which seems to be redundand to me since the whole area was zeroed out earlier. [And "memcpy(d,s,0)" is a noop, right?]

Am I missing something?

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
You can love it, change it, or leave it.    There is NO other option.
But do not complain - it is your own choice...                  -- wd