lkml.org 
[lkml]   [2016]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: scripts/basic/bin2c: Complete error handling in main()
2016-11-03 2:48 GMT+09:00 SF Markus Elfring <elfring@users.sourceforge.net>:
>> Is replacing printf("\"\n") with puts("\"") optimization?
>
> Is the difference relevant if an “ordinary” string is passed instead of
> a format string?

I think GCC does the replacement automatically
unless -ffreestanding option is given.


With a quick test, I got the following disassembly

0000000000400440 <main>:
400440: 48 83 ec 08 sub $0x8,%rsp
400444: bf c4 05 40 00 mov $0x4005c4,%edi
400449: e8 c2 ff ff ff callq 400410 <puts@plt>
40044e: 31 c0 xor %eax,%eax
400450: 48 83 c4 08 add $0x8,%rsp
400454: c3 retq

from the following program:

int main(void)
{
printf("hello, world\n");
return 0;
}




>
>> Frankly, the result of this patch seems extremely unreadable code.
>
> Do you care for more complete error detection and corresponding exception handling
> in this source file?


I like the code as is.

Such error checks and magic numbers are messy.



--
Best Regards
Masahiro Yamada

\
 
 \ /
  Last update: 2016-11-02 19:28    [W:0.071 / U:0.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site