This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RedBoot: Cleanup excessive indirection in option argument handling.


Hi,

RedBoot's init_opts()/scan_opts() use an excessive level of indirection for the handling of option arguments. GCC 3.3 chokes on it with warnings about "dereferencing type-punned pointer will break strict-aliasing rules".

Expect a patch later cleaning up all the typecasts in the init_opts()/scan_opts() calls.

2003-09-30 David Vrabel <dvrabel@arcom.com>

	* include/redboot.h, src/parse.c (init_opts, scan_opts): Remove
	the excessive level of indirection in the handling of option
	arguments.

David Vrabel
--
David Vrabel, Design Engineer

Arcom                         Tel: +44 (0)1223 411200 ext. 3233
Clifton Road                  Fax: +44 (0)1223 403400
Cambridge CB1 7EA             E-mail: dvrabel@arcom.com
UK                            Web: http://www.arcom.com/


________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs Email Security System. For more information on a proactive email security service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________
===================================================================
RCS file: /var/cvs/ecos/packages/redboot/current/include/redboot.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- ecos/packages/redboot/current/include/redboot.h	2003/08/29 10:11:35	1.1.1.2
+++ ecos/packages/redboot/current/include/redboot.h	2003/09/30 16:46:10	1.2
@@ -280,7 +280,7 @@
     char flag;
     bool takes_arg;
     int  arg_type;
-    void **arg;
+    void *arg;
     bool *arg_set;
     char *name;
 };
@@ -293,10 +293,10 @@
 externC struct cmd *parse(char **line, int *argc, char **argv);
 
 externC void init_opts(struct option_info *opts, char flag, bool takes_arg, 
-                       int arg_type, void **arg, bool *arg_set, char *name);
+                       int arg_type, void *arg, bool *arg_set, char *name);
 externC bool scan_opts(int argc, char *argv[], int first, 
                        struct option_info *opts, int num_opts, 
-                       void **def_arg, int def_arg_type, char *def_descr);
+                       void *def_arg, int def_arg_type, char *def_descr);
 
 #ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS
 #define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
===================================================================
RCS file: /var/cvs/ecos/packages/redboot/current/src/parse.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ecos/packages/redboot/current/src/parse.c	2003/05/29 10:55:49	1.1
+++ ecos/packages/redboot/current/src/parse.c	2003/09/30 16:46:10	1.2
@@ -200,7 +200,7 @@
 //
 void
 init_opts(struct option_info *opts, char flag, bool takes_arg, 
-          int arg_type, void **arg, bool *arg_set, char *name)
+          int arg_type, void *arg, bool *arg_set, char *name)
 {
     opts->flag = flag;
     opts->takes_arg = takes_arg;
@@ -216,7 +216,7 @@
 bool
 scan_opts(int argc, char *argv[], int first, 
           struct option_info *opts, int num_opts, 
-          void **def_arg, int def_arg_type, char *def_descr)
+          void *def_arg, int def_arg_type, char *def_descr)
 {
     bool ret = true;
     bool flag_ok;
@@ -226,7 +226,7 @@
     struct option_info *opt;
 
     if (def_arg && (def_arg_type == OPTION_ARG_TYPE_STR)) {
-        *def_arg = (char *)0;
+        *(char **)def_arg = (char *)0;
     }
     opt = opts;
     for (j = 0;  j < num_opts;  j++, opt++) {
@@ -271,7 +271,7 @@
                             }
                             break;
                         case OPTION_ARG_TYPE_STR:
-                            *opt->arg = s;
+                            *(char **)opt->arg = s;
                             break;
                         }
                         *opt->arg_set = true;
@@ -308,7 +308,7 @@
                     }
                     break;
                 case OPTION_ARG_TYPE_STR:
-                    *def_arg = argv[i];
+                    *(char **)def_arg = argv[i];
                     break;
                 }
                 def_arg_set = true;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]