1. 14
  1. 3
    char *t;
    t = (char *) s;

    This can be simplified to:

    const char *t = s

    const char* means ‘mutable pointer to const character’, so the const doesn’t need to be casted away. And even in c89, variables can be initialized when declared.

    1. 0

      I really wish people wouldn’t teach at&t assembly syntax.

      It’s less intuitive than the intel syntax, and few tools aside from GNU’s use it. And the GNU tools (assembler, compiler, gdb, objdump) will use intel syntax if you ask nicely. I will admit, [dword ptr] and friends are a bit ugly, but they’re usually inferred. And dest, src makes so much more sense than src, dest. It is more familiar to users of higher-level languages; but more to the point, it emphasizes the sites of mutation by putting them first. And operand addressing in at&t is just ridiculous compared with intel.

      1. 2

        Funny, I’ve always felt exactly the opposite. GAS syntax strikes me as pleasant and elegant, and Intel as reminiscent of banging rocks together.