Re: [U-Boot] [PATCH v2 04/17] env: move extern environment[] to environment.h

2011-11-27 Thread Igor Grinberg
Hi Mike,

On 11/25/11 23:12, Mike Frysinger wrote:
> On Thursday 17 November 2011 11:07:23 Igor Grinberg wrote:
>> --- a/tools/envcrc.c
>> +++ b/tools/envcrc.c
>>
>>  #if defined(ENV_IS_EMBEDDED) && !defined(CONFIG_BUILD_ENVCRC)
>> +# include 
>>  # define CONFIG_BUILD_ENVCRC 1
>>  #endif
>> ...
>>  #ifdef CONFIG_BUILD_ENVCRC
>>  extern unsigned int env_size;
>> -extern unsigned char environment;
>> +extern env_t environment;
>>  #endif  /* CONFIG_BUILD_ENVCRC */
> 
> this breaks when CONFIG_BUILD_ENVCRC is defined.  you include environment.h 
> when it isn't defined, but then use env_t when it is defined.

Good... eh.. I mean Bad! Thanks for testing/reporting.

Can you, please, supply the error log, so I can include it in the
fix commit message?

Thanks

-- 
Regards,
Igor.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 04/17] env: move extern environment[] to environment.h

2011-11-25 Thread Mike Frysinger
On Thursday 17 November 2011 11:07:23 Igor Grinberg wrote:
> --- a/tools/envcrc.c
> +++ b/tools/envcrc.c
> 
>  #if defined(ENV_IS_EMBEDDED) && !defined(CONFIG_BUILD_ENVCRC)
> +# include 
>  # define CONFIG_BUILD_ENVCRC 1
>  #endif
> ...
>  #ifdef CONFIG_BUILD_ENVCRC
>  extern unsigned int env_size;
> -extern unsigned char environment;
> +extern env_t environment;
>  #endif   /* CONFIG_BUILD_ENVCRC */

this breaks when CONFIG_BUILD_ENVCRC is defined.  you include environment.h 
when it isn't defined, but then use env_t when it is defined.
-mike


signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 04/17] env: move extern environment[] to environment.h

2011-11-17 Thread Igor Grinberg
Extract all extern declarations for environment out of c files
into the environment.h header.

Signed-off-by: Igor Grinberg 
---
v2: fix compilation for envcrc.c by including environment.h
(Thanks Stefano)

 common/env_flash.c|4 +---
 common/env_mmc.c  |3 +--
 common/env_nand.c |3 +--
 common/env_onenand.c  |6 +-
 include/environment.h |4 
 tools/envcrc.c|5 +++--
 6 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/common/env_flash.c b/common/env_flash.c
index 1383f3c..a32bfcf 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -49,9 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;
 char * env_name_spec = "Flash";
 
 #ifdef ENV_IS_EMBEDDED
-
-extern uchar environment[];
-env_t *env_ptr = (env_t *)(&environment[0]);
+env_t *env_ptr = &environment;
 
 static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
 
diff --git a/common/env_mmc.c b/common/env_mmc.c
index a0c0ece..cb75887 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -35,8 +35,7 @@
 char *env_name_spec = "MMC";
 
 #ifdef ENV_IS_EMBEDDED
-extern uchar environment[];
-env_t *env_ptr = (env_t *)(&environment[0]);
+env_t *env_ptr = &environment;
 #else /* ! ENV_IS_EMBEDDED */
 env_t *env_ptr = NULL;
 #endif /* ENV_IS_EMBEDDED */
diff --git a/common/env_nand.c b/common/env_nand.c
index 94d4417..d975322 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -59,8 +59,7 @@ char *env_name_spec = "NAND";
 
 
 #if defined(ENV_IS_EMBEDDED)
-extern uchar environment[];
-env_t *env_ptr = (env_t *)(&environment[0]);
+env_t *env_ptr = &environment;
 #elif defined(CONFIG_NAND_ENV_DST)
 env_t *env_ptr = (env_t *)CONFIG_NAND_ENV_DST;
 #else /* ! ENV_IS_EMBEDDED */
diff --git a/common/env_onenand.c b/common/env_onenand.c
index b1f266b..c09fdf3 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -44,10 +44,6 @@ char *env_name_spec = "OneNAND";
 #define ONENAND_MAX_ENV_SIZE   4096
 #define ONENAND_ENV_SIZE(mtd)  (ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE)
 
-#ifdef ENV_IS_EMBEDDED
-extern uchar environment[];
-#endif /* ENV_IS_EMBEDDED */
-
 DECLARE_GLOBAL_DATA_PTR;
 
 uchar env_get_char_spec(int index)
@@ -64,7 +60,7 @@ void env_relocate_spec(void)
int rc;
size_t retlen;
 #ifdef ENV_IS_EMBEDDED
-   char *buf = (char *)&environment[0];
+   char *buf = (char *)&environment;
 #else
loff_t env_addr = CONFIG_ENV_ADDR;
char onenand_env[ONENAND_MAX_ENV_SIZE];
diff --git a/include/environment.h b/include/environment.h
index 20775da..951803f 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -154,6 +154,10 @@ typedef struct environment_s {
unsigned char   data[ENV_SIZE]; /* Environment data */
 } env_t;
 
+#ifdef ENV_IS_EMBEDDED
+extern env_t environment;
+#endif /* ENV_IS_EMBEDDED */
+
 extern const unsigned char default_environment[];
 
 #ifndef DO_DEPS_ONLY
diff --git a/tools/envcrc.c b/tools/envcrc.c
index feebbab..111d9f6 100644
--- a/tools/envcrc.c
+++ b/tools/envcrc.c
@@ -61,6 +61,7 @@
 #endif /* CONFIG_ENV_IS_IN_FLASH */
 
 #if defined(ENV_IS_EMBEDDED) && !defined(CONFIG_BUILD_ENVCRC)
+# include 
 # define CONFIG_BUILD_ENVCRC 1
 #endif
 
@@ -77,7 +78,7 @@ extern uint32_t crc32 (uint32_t, const unsigned char *, 
unsigned int);
 
 #ifdef CONFIG_BUILD_ENVCRC
 extern unsigned int env_size;
-extern unsigned char environment;
+extern env_t environment;
 #endif /* CONFIG_BUILD_ENVCRC */
 
 int main (int argc, char **argv)
@@ -85,7 +86,7 @@ int main (int argc, char **argv)
 #ifdef CONFIG_BUILD_ENVCRC
unsigned char pad = 0x00;
uint32_t crc;
-   unsigned char *envptr = &environment,
+   unsigned char *envptr = (unsigned char *)&environment,
*dataptr = envptr + ENV_HEADER_SIZE;
unsigned int datasize = ENV_SIZE;
unsigned int eoe;
-- 
1.7.3.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot