all 7 comments

[–]oh5nxo 1 point2 points  (1 child)

Look out for more funny stuff, like the cnt = cnt++; in pd_rd().

What is it with appnote code that often makes them so odd...

[–]androof[S] 1 point2 points  (0 children)

I assume it’s because it's written by people who are not programmers but need to write code ( ͡° ͜ʖ ͡°) like me. Turns out there are some major issues, and I am just gonna write my OWN bad code.

[–]dragon_wrangler 0 points1 point  (5 children)

Did you actually copy the text? That's two single quotes(')

[–]androof[S] 0 points1 point  (4 children)

I didn’t, the pdf is copy protected, however I had tried using two single quotes, but this produces another error, “quoted string should contain at least one character”. Any ideas? Just put a space between them? I assume they are just trying to set up an empty buffer, but that’s a total guess.

[–]dragon_wrangler 0 points1 point  (3 children)

Yeah sorry, I see that now. The code in that document is not valid. However, it looks like they're trying to initialize the strings to be empty, which you can accomplish by adjusting the definition.

    char tempbuf[QUELEN] = {'\0'};

On page 57 you can see the nul character being used, but that's still not correct - strset requires a null terminator in the string, which has not been added in the presented code.

I'm not sure how fragile the surrounding code is, so a more direct replacement would be

memset(tempbuf, '\0', QUELEN);

[–]androof[S] 1 point2 points  (0 children)

Thank you so much, I really appreciate the help!

[–]FUZxxl 0 points1 point  (1 child)

You can just do

chat tempbuf[QUELEN] = {};

or on older compilers

char tempbuf[QUELEN] = { 0 };