Hello!

Kumar Gala schrieb:
> Add a simple expr command that will set an env variable as the result
> of the command.

Good idea! I have been missing this for a long time but I also was too
lazy to implement it.

> +     /* Validate arguments */
> +     if ((argc != 5)) {
> +             printf("Usage:\n%s\n", cmdtp->usage);
> +             return 1;
> +     }

It should also be checked if the operator has a length of exactly
one character in order to prevent typos.

+       /* Validate arguments */
+       if ((argc != 5) || (strlen(argv[3]) != 1)) {
+               printf("Usage:\n%s\n", cmdtp->usage);
+               return 1;
+       }

May we rely on the compiler optimizing the above expression so
strlen() != 1 will only be evaluated if argc == 5 ? Probably we
have to write

+       ulong a, b;
+       char buf[16];
+       int valid = 0;
+
+       /* Validate arguments */
+       if (argc == 5) {
+               if (strlen(argv[3]) == 1) {
+                       valid = 1;
+               }
+       }
+       if (!valid) {
+               printf("Usage:\n%s\n", cmdtp->usage);
+               return 1;
+       }

Regards
Andreas Schweigstill


-- 
Dipl.-Phys. Andreas Schweigstill
Schweigstill IT | Embedded Systems
Schauenburgerstraße 116, D-24118 Kiel, Germany
Phone: (+49) 431 5606-435, Fax: (+49) 431 5606-436
Mobile: (+49) 171 6921973, Web: http://www.schweigstill.de/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Reply via email to