Date: Tue, 30 Jul 2013 09:50:16 +0200 From: Dániel Bali <balijanosdaniel@...il.com> To: john-dev@...ts.openwall.com Subject: Re: Daniel's weekly report #7 On Jul 30, 2013 3:53 AM, "Solar Designer" <solar@...nwall.com> wrote: > Here's the corresponding commit: > > https://github.com/balidani/gcnasm/commit/9adcd876b389d4296f2f217577bd95906142478a > > Do we really need this? I think that for any serious use we'd be > passing our source code through cpp, which includes more complete macro > support. I don't mind having this functionality in, though. By passing source code through cpp do you mean the GCN ISA source? So we would be doing some sort of static analysis and optimize that way? This will only be useful when writing GCN ISA code by hand. > Speaking of your C code, instead of the calloc() + strncpy(), you may > use strdup(). strncpy() is very rarely the best choice; I suggest that > you only use it when you need its NUL padding feature. You're misusing > strncpy() for a possibly slower alternative to memcpy() - really, you > tell it exactly how many chars to copy and don't give it a chance to do > anything else anyway. In cases when you do need to have the copying > limited to the target buffer size (not the case here), you may use e.g. > this trick: > > dst = '\0'; > strncat(dst, src, sizeof(dst) - 1); > > Note that strncat() guarantees NUL termination, and does not do the > usually unnecessary NUL padding (which strncpy() does). > > Also, ctype macros such as toupper() are only defined to work on "int", > so using them on "char" is potentially problematic (although many libc's > include a workaround for this common misuse). For proper use, you'd > cast your "char" to "unsigned char" and only then to "int" (one of these > can be implied, such as via an assignment). Thank you, I will fix these. Regards, Daniel Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.