Re: scripts/basic/bin2c: Complete error handling in main()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2016-11-03 2:48 GMT+09:00 SF Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>:
>> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux