Skip to contentSkip to conversation

environment, netconsole: reducing packages when printing environment variables

PATCH New Heiko Schocher 3 participants 6 messages Jan 28, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 2/31 environment, netconsole: reducing packages when printing environment variables

Actual, do_printenv () uses putc () to print the Environment- variables. If using netconsole, this will result in a lot of packages with single characters in it. With the new config option CONFIG_ENV_BUFFER_PRINT do_printenv () uses now puts () to print a complete Environmentvariable, so the number of packages when using netconsole are reduced.

---
 common/cmd_nvedit.c      |    8 ++++++++
 include/configs/mgcoge.h |    1 +
 include/configs/mgsuvd.h |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_nvedit.c +8 -0
index 85025da..8f6310a 100644
@@ -89,8 +89,12 @@ int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
 			for (nxt=i; env_get_char(nxt) != '\0'; ++nxt)
 				;
+#if defined(CONFIG_ENV_BUFFER_PRINT)
+			puts ((char *)( env_get_addr(nxt) + 1));
+#else
 			for (k=i; k<nxt; ++k)
 				putc(env_get_char(k));
+#endif
 			putc  ('\n');
 
 			if (ctrlc()) {
@@ -118,11 +122,15 @@ int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 			if (k < 0) {
 				continue;
 			}
+#if defined(CONFIG_ENV_BUFFER_PRINT)
+			printf ("%s=%s\n", name, (char *)( env_get_addr(k)));
+#else
 			puts (name);
 			putc ('=');
 			while (k < nxt)
 				putc(env_get_char(k++));
 			putc ('\n');
+#endif
 			break;
 		}
 		if (k < 0) {
include/configs/mgcoge.h +1 -0
index 233bee0..9416a03 100644
@@ -139,6 +139,7 @@
 #define CONFIG_ENV_OFFSET_REDUND	(CONFIG_ENV_OFFSET + CONFIG_ENV_SECT_SIZE)
 #define CONFIG_ENV_SIZE_REDUND		(CONFIG_ENV_SIZE)
 #endif /* CONFIG_ENV_IS_IN_FLASH */
+#define CONFIG_ENV_BUFFER_PRINT		1
 
 /* enable I2C and select the hardware/software driver */
 #undef	CONFIG_HARD_I2C			/* I2C with hardware support	*/
include/configs/mgsuvd.h +1 -0
index 8f82751..698f0e7 100644
@@ -143,6 +143,7 @@
 /* Address and size of Redundant Environment Sector	*/
 #define CONFIG_ENV_OFFSET_REDUND	(CONFIG_ENV_OFFSET+CONFIG_ENV_SECT_SIZE)
 #define CONFIG_ENV_SIZE_REDUND	(CONFIG_ENV_SIZE)
+#define CONFIG_ENV_BUFFER_PRINT		1
 
 /*-----------------------------------------------------------------------
  * Cache Configuration
Signature · 5 lines
1.6.0.6

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#1 lore raw

PATCH 2/31 environment, netconsole: reducing packages when printing environment variables

Hi Heiko,

Quoted 6 lines · Heiko Schocher

Actual, do_printenv () uses putc () to print the Environment- variables. If using netconsole, this will result in a lot of packages with single characters in it. With the new config option CONFIG_ENV_BUFFER_PRINT do_printenv () uses now puts () to print a complete Environmentvariable, so the number of packages when using netconsole are reduced.

Wouldn't it make sense to use this new code (in the CONFIG_ENV_BUFFER_PRINT sections) unconditionally instead of the old version? The source would look nicer and the resulting image probably smaller.

Some nitpicking comments below.

Quoted 12 lines
---
 common/cmd_nvedit.c      |    8 ++++++++
 include/configs/mgcoge.h |    1 +
 include/configs/mgsuvd.h |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_nvedit.c +0 -0
index 85025da..8f6310a 100644

common/cmd_nvedit.c int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, · line 93

Quoted 5 lines
common/cmd_nvedit.c +2 -0
@@ -89,8 +89,12 @@ int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc,
 char *argv[]) for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
 			for (nxt=i; env_get_char(nxt) != '\0'; ++nxt)
 				;
+#if defined(CONFIG_ENV_BUFFER_PRINT)
+			puts ((char *)( env_get_addr(nxt) + 1));

Please stick with one coding-style rule, either "func ()" or "func()". Since this file already uses the "func()" style I suggest to use this version.

common/cmd_nvedit.c int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 98

Quoted 5 lines
common/cmd_nvedit.c +2 -0
+#else
 			for (k=i; k<nxt; ++k)
 				putc(env_get_char(k));
+#endif
 			putc  ('\n');

Why not fold this "putc()" into the puts() above (replace it with printf)?

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

#2 lore raw

PATCH 2/31 environment, netconsole: reducing packages when printing environment variables

Hello Stefan,

Quoted 11 lines · Stefan Roese
Quoted 6 lines · Heiko Schocher

Actual, do_printenv () uses putc () to print the Environment- variables. If using netconsole, this will result in a lot of packages with single characters in it. With the new config option CONFIG_ENV_BUFFER_PRINT do_printenv () uses now puts () to print a complete Environmentvariable, so the number of packages when using netconsole are reduced.

Wouldn't it make sense to use this new code (in the CONFIG_ENV_BUFFER_PRINT sections) unconditionally instead of the old version? The source would look nicer and the resulting image probably smaller.

I' ll aggree with you. Is this is ok for all?

Quoted 9 lines

Some nitpicking comments below.

Quoted 7 lines
---
 common/cmd_nvedit.c      |    8 ++++++++
 include/configs/mgcoge.h |    1 +
 include/configs/mgsuvd.h |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)
Quoted 13 lines

common/cmd_nvedit.c int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, · line 93

Quoted 10 lines
common/cmd_nvedit.c +2 -0
index 85025da..8f6310a 100644
@@ -89,8 +89,12 @@ int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc,
 char *argv[]) for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
 			for (nxt=i; env_get_char(nxt) != '\0'; ++nxt)
 				;
+#if defined(CONFIG_ENV_BUFFER_PRINT)
+			puts ((char *)( env_get_addr(nxt) + 1));

Please stick with one coding-style rule, either "func ()" or "func()". Since this file already uses the "func()" style I suggest to use this version.

OK.

Quoted 7 lines

common/cmd_nvedit.c int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 98

Quoted 5 lines
common/cmd_nvedit.c +2 -0
+#else
 			for (k=i; k<nxt; ++k)
 				putc(env_get_char(k));
+#endif
 			putc  ('\n');

Why not fold this "putc()" into the puts() above (replace it with printf)?

I make it in a printf (Think there was no reason for not doing it so)

thanks
bye
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#3 lore raw

PATCH 2/31 environment, netconsole: reducing packages when printing environment variables

Dear Heiko Schocher,

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

Why not fold this "putc()" into the puts() above (replace it with printf)?

I make it in a printf (Think there was no reason for not doing it so)

Check if printf() is not printing a series of single characters again! Also, we tend to prefer using puts() / putc() over printf() because of the huge performance overhead involved in printf() when only plain constant strings need to be printed.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Sometimes a man will tell his bartender things he'll never tell his doctor.
	-- Dr. Phillip Boyce, "The Menagerie" ("The Cage"),
	   stardate unknown.
#4 lore raw

PATCH 2/31 environment, netconsole: reducing packages when printing environment variables

Quoted 9 lines · Wolfgang Denk
Quoted 4 lines
Quoted 2 lines

Why not fold this "putc()" into the puts() above (replace it with printf)?

I make it in a printf (Think there was no reason for not doing it so)

Check if printf() is not printing a series of single characters again! Also, we tend to prefer using puts() / putc() over printf() because of the huge performance overhead involved in printf() when only plain constant strings need to be printed.

printf() is already used in the 2nd part of the patch. But the 1st string can also be concat-ed of course and printed via puts(). printf() would be easier to read though from my point of view.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

#5 lore raw

PATCH 2/31 environment, netconsole: reducing packages when printing environment variables

Dear Stefan Roese,

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

Check if printf() is not printing a series of single characters again! Also, we tend to prefer using puts() / putc() over printf() because of the huge performance overhead involved in printf() when only plain constant strings need to be printed.

printf() is already used in the 2nd part of the patch. But the 1st string can also be concat-ed of course and printed via puts(). printf() would be easier to read though from my point of view.

Just because you are slow in one place (where you need the formatting capabilities of printf()) is no excuse for being slow in other parts (where you don't need it).

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The two most common things in the universe are hydrogen  and  stupi-
dity."