Skip to contentSkip to conversation

Small fixes in barebox

PATCH Superseded Alexander Aring 2 participants 11 messages Feb 7, 2013 – Feb 8, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Small fixes in barebox

First I tried to change getopt optstring argument to "const char *" and I test it with an allyesconfig for compiler warnings.

Then there popup some compile errors, which I tried to fix.

I am not happy with some of these solutions. Maybe someone have an idea how we can make it better.

hush: add getopt only if it enabled
- I don't know if this needs a fix. But if we disable getopt there is a no-op getopt implementation in the command list. This patch don't add getopt to the command list at runtime, but the no-op implementation is still there. Maybe a compiletime solution is better to remove the no-op implementation.

sata-imx: fix depends on ARCH_IMX
- I am not sure but this looks like ARCH_IMX related things. I got a error that some imx51 header files could'nt be found.

net: fix cpsw depends on ARCH_OMAP
- Same thing like sata-imx. I got a compile error that mach/cpsw.h wasn't found. I only found that in the omap implementation.

Another (maybe toolchain related issue) is:
barebox/lib/libubigen.c:105: undefined reference to `__divdi3'

Is it in this line:

tmp = (vi->bytes + ui->leb_size - 1) / ui->leb_size;

If we know that ui->leb_size is a power-of-two, we can use a shift for this instead of division. But I don't know if leb_size a power-of-two number.

Alexander Aring (4):
hush: add getopt only if it enabled
getopt: change optstring to const char*
sata-imx: fix depends on ARCH_IMX
net: fix cpsw depends on ARCH_OMAP

 common/hush.c       | 3 ++-
 drivers/ata/Kconfig | 1 +
 drivers/net/Kconfig | 1 +
 include/getopt.h    | 2 +-
 lib/getopt.c        | 4 ++--
 5 files changed, 7 insertions(+), 4 deletions(-)
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/4 hush: add getopt only if it enabled

This patch add getopt to the command list if it enabled via Kconfig. With this patch we get a 'command not found' error. Otherwise getopt doing nothing.

---
 common/hush.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/hush.c +2 -1
index 1f468f6..602f8f1 100644
@@ -782,7 +782,8 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi)
 
 	remove_quotes(globbuf.gl_pathc, globbuf.gl_pathv);
 
-	if (!strcmp(globbuf.gl_pathv[0], "getopt")) {
+	if (!strcmp(globbuf.gl_pathv[0], "getopt") &&
+			IS_ENABLED(CONFIG_HUSH_GETOPT)) {
 		ret = builtin_getopt(ctx, child, globbuf.gl_pathc, globbuf.gl_pathv);
 	} else if (!strcmp(globbuf.gl_pathv[0], "exit")) {
 		ret = builtin_exit(ctx, child, globbuf.gl_pathc, globbuf.gl_pathv);
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/4 getopt: change optstring to const char*

In reply to Alexander Aring

Change getopt optstring parameter type to const char *. Also change type to const char * of tmp variable which pointed to optstring. This will only handle readonly.

---
 include/getopt.h | 2 +-
 lib/getopt.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/getopt.h +1 -1
index f23175f..4f48ba8 100644
@@ -35,7 +35,7 @@ extern char *optarg;
  * - options can be mixed with nonoptions (like ls /bin -R)
  */
 
-int getopt(int argc, char *argv[], char *optstring);
+int getopt(int argc, char *argv[], const char *optstring);
 
 struct getopt_context {
 	int opterr;
lib/getopt.c +2 -2
index ead9150..fd12a88 100644
@@ -56,10 +56,10 @@ void getopt_context_restore(struct getopt_context *gc)
 }
 EXPORT_SYMBOL(getopt_context_restore);
 
-int getopt(int argc, char *argv[], char *optstring)
+int getopt(int argc, char *argv[], const char *optstring)
 {
 	char curopt;   /* current option character */
-	char *curoptp; /* pointer to the current option in optstring */
+	const char *curoptp; /* pointer to the current option in optstring */
 
 	while(1) {
 		debug("optindex: %d nonopts: %d optind: %d\n", optindex, nonopts, optind);
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/4 sata-imx: fix depends on ARCH_IMX

In reply to Alexander Aring
---
 drivers/ata/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/ata/Kconfig +1 -0
index ff6528a..42f2065 100644
@@ -38,6 +38,7 @@ config DISK_AHCI
 	select DISK_DRIVE
 
 config DISK_AHCI_IMX
+	depends on ARCH_IMX
 	depends on DISK_AHCI
 	bool "i.MX AHCI support"
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 4/4 net: fix cpsw depends on ARCH_OMAP

In reply to Alexander Aring

drivers/net/cpsw.c:34:23: fatal error: mach/cpsw.h: No such file or directory

---
 drivers/net/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/net/Kconfig +1 -0
index cf6ceee..2b7decd 100644
@@ -33,6 +33,7 @@ config DRIVER_NET_CS8900
 
 config DRIVER_NET_CPSW
 	bool "CPSW ethernet driver"
+	depends on ARCH_OMAP
 	select PHYLIB
 
 config DRIVER_NET_SMC911X
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw
In reply to Alexander Aring
Quoted 8 lines · Alexander Aring

First I tried to change getopt optstring argument to "const char *" and I test it with an allyesconfig for compiler warnings.

Then there popup some compile errors, which I tried to fix.

I am not happy with some of these solutions. Maybe someone have an idea how we can make it better.

Quoted 6 lines

hush: add getopt only if it enabled
- I don't know if this needs a fix. But if we disable getopt there is a no-op getopt implementation in the command list. This patch don't add getopt to the command list at runtime, but the no-op implementation is still there. Maybe a compiletime solution is better to remove the no-op implementation.

I don't understand. getopt is not there if CONFIG_HUSH_GETOPT is disabled. It's ifdeffed out.

Quoted 4 lines

sata-imx: fix depends on ARCH_IMX
- I am not sure but this looks like ARCH_IMX related things. I got a error that some imx51 header files could'nt be found.

That's fine you did this. Another option would be to move the header file to include/, but currently this is not worth it.

Quoted 4 lines

net: fix cpsw depends on ARCH_OMAP
- Same thing like sata-imx. I got a compile error that mach/cpsw.h wasn't found. I only found that in the omap implementation.

Also fine.

Quoted 11 lines

Another (maybe toolchain related issue) is:
barebox/lib/libubigen.c:105: undefined reference to `__divdi3'

Is it in this line:

tmp = (vi->bytes + ui->leb_size - 1) / ui->leb_size;

If we know that ui->leb_size is a power-of-two, we can use a shift for this instead of division. But I don't know if leb_size a power-of-two number.

leb_size (logical erase block size) is never a power of two. This is the peb size (physical erase block size) minus the ubi metadata.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw
Quoted 16 lines · Sascha Hauer
Quoted 8 lines · Alexander Aring

First I tried to change getopt optstring argument to "const char *" and I test it with an allyesconfig for compiler warnings.

Then there popup some compile errors, which I tried to fix.

I am not happy with some of these solutions. Maybe someone have an idea how we can make it better.

Quoted 6 lines

hush: add getopt only if it enabled
- I don't know if this needs a fix. But if we disable getopt there is a no-op getopt implementation in the command list. This patch don't add getopt to the command list at runtime, but the no-op implementation is still there. Maybe a compiletime solution is better to remove the no-op implementation.

Quoted 2 lines

I don't understand. getopt is not there if CONFIG_HUSH_GETOPT is disabled. It's ifdeffed out.

Ah, now I got it. You miss the 'unknown command... message'. Then the patch seems fine.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

Hi,

Quoted 17 lines · Sascha Hauer
Quoted 16 lines · Sascha Hauer
Quoted 14 lines · Alexander Aring

First I tried to change getopt optstring argument to "const char *" and I test it with an allyesconfig for compiler warnings.

Then there popup some compile errors, which I tried to fix.

I am not happy with some of these solutions. Maybe someone have an idea how we can make it better.

hush: add getopt only if it enabled
- I don't know if this needs a fix. But if we disable getopt there is a no-op getopt implementation in the command list. This patch don't add getopt to the command list at runtime, but the no-op implementation is still there. Maybe a compiletime solution is better to remove the no-op implementation.

Quoted 6 lines
Quoted 2 lines

I don't understand. getopt is not there if CONFIG_HUSH_GETOPT is disabled. It's ifdeffed out.

Ah, now I got it. You miss the 'unknown command... message'. Then the patch seems fine.

Yea, it's only a small thing... I don't know if this is necessary. :-) Maybe there is a special reason for that no error occurs.

Regards
Alex

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#9 lore raw
Quoted 23 lines · Alexander Aring

Hi,

Quoted 20 lines · Sascha Hauer
Quoted 18 lines · Sascha Hauer
Quoted 8 lines · Alexander Aring

First I tried to change getopt optstring argument to "const char *" and I test it with an allyesconfig for compiler warnings.

Then there popup some compile errors, which I tried to fix.

I am not happy with some of these solutions. Maybe someone have an idea how we can make it better.

Quoted 6 lines

hush: add getopt only if it enabled
- I don't know if this needs a fix. But if we disable getopt there is a no-op getopt implementation in the command list. This patch don't add getopt to the command list at runtime, but the no-op implementation is still there. Maybe a compiletime solution is better to remove the no-op implementation.

I don't understand. getopt is not there if CONFIG_HUSH_GETOPT is disabled. It's ifdeffed out.

Quoted 6 lines
Quoted 3 lines

Ah, now I got it. You miss the 'unknown command... message'. Then the patch seems fine.

Yea, it's only a small thing... I don't know if this is necessary. :-) Maybe there is a special reason for that no error occurs.

Well the patch will result in dropping the unnecessary strcmp, so a slightly smaller binary.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw
In reply to Sascha Hauer

Hi Sascha,

Quoted 16 lines · Sascha Hauer
Quoted 8 lines · Alexander Aring

First I tried to change getopt optstring argument to "const char *" and I test it with an allyesconfig for compiler warnings.

Then there popup some compile errors, which I tried to fix.

I am not happy with some of these solutions. Maybe someone have an idea how we can make it better.

Quoted 6 lines

hush: add getopt only if it enabled
- I don't know if this needs a fix. But if we disable getopt there is a no-op getopt implementation in the command list. This patch don't add getopt to the command list at runtime, but the no-op implementation is still there. Maybe a compiletime solution is better to remove the no-op implementation.

Quoted 3 lines

I don't understand. getopt is not there if CONFIG_HUSH_GETOPT is disabled. It's ifdeffed out.

Yes it's ifdeffed out with an empty no-op getopt implementation. But this will be add to the barebox command list.

So if we type "getopt" we don't get a "Unknown command" message, barebox run only a no-op getopt implementation.

This patch will don't add getopt to the command list if we don't enable it. I let the no-op getopt implementation there, otherwise we get a compiler warning.

Regards
Alex

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox