This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

Re: [patch] libgloss/arm: Cast arguments to do_AngelSWI to int.


Hi Paul

   union foo {
     int i;
     void * p;
   } block [2];
   block[0].p = path;
   block[1].i = strlen (path);

You really think that's better?

Better than casting a pointer to an int ? Yes.


If you're doing is *properly* you have separate structures for each syscall, and use those rather than a simple "block" array.

Well the block array in this case is really just anonymous arguments to the syscall, so having a separate structure for each variant seems over the top to me.


I take your point about the union being a little heavy handed for what is being coded here, but given the number of subtle problems that can be caused by aliasing, I think that it is wise to always code pointer to integer conversions using unions, even when they do not appear to be necessary. Better safe than sorry.

Cheers
  Nick


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