News for hackers. Stuff that matters.
Re:Certificate Verification Issue - GnuTLS by valarauca1 on Tuesday March 04, 2014 @04:53PM (#7343474)
One of his complaints is that they aren't using bools, when bools don't exist in c.
Re:Certificate Verification Issue - GnuTLS by DannyBee on Tuesday March 04, 2014 @04:58PM (#7343506)
Sure they do, since c99. Section 7.16
Re:Certificate Verification Issue - GnuTLS by LnxPrgr3 on Tuesday March 04, 2014 @07:44PM (#7344431)
Even before then, C had the concept of a boolean expression, and ints were used idiomatically as bools.

Unfortunately, the type system can't save you, so it's up to you to keep your promise to return the correct thing. Not even C99 can save you:

    $ cat booltest.c 
    #include <stdio.h>
    #include <stdbool.h>
    
    bool moo() {
        int rv = -1;
        return rv;
    }
    
    int main(int argc, char *argv[]) {
        printf("moo() returned %s\n", moo() ? "TRUE" : "FALSE");
    }
    $ clang -std=c99 -o booltest booltest.c -Wall
    $
Re:Certificate Verification Issue - GnuTLS by bodyfour on Tuesday March 04, 2014 @10:09PM (#7345007)
I'm usually not much of a Java fan, but making bool a stricter type was a good change. I always write my C code as if it had the same rules. For example, if you have:

    bool b;
    int i;
    unsigned u;
    void *p;
You could write code that looked like:

    if (b && i && u && p)
...and some people would even consider that idiomatic. I'd write the same test as:

    if (b && (i != 0) && (u > 0) && (p != NULL))
which is a little longer but, IMO, clearer. If the compiler enforced that style this family of bug would happen a lot less.

In a similar vein, I wish enums had strict conversion rules. C++11 finally gives us that with "enum class", but I don't think anything similar exists in C.

Re:Certificate Verification Issue - GnuTLS by valarauca1 on Tuesday March 04, 2014 @05:18PM (#7343623)
I'm pretty sure that just char's and a little pre-processor hand waving.
Re:Certificate Verification Issue - GnuTLS by fnordfnordfnord on Tuesday March 04, 2014 @05:24PM (#7343640)
s/his/her/
Re:Certificate Verification Issue - GnuTLS by abadidea on Tuesday March 04, 2014 @06:57PM (#7344173)
If by "he" you mean the person who drew the picture:

First, I absolutely LOVE it when people assume I'm a dude. Plot twist: no I don't. If you don't know someone's gender, getting it wrong with an assumption is a good way to hack them off.

Second: the function is explicitly prototyped as returning bool (I highlighted this in neon green) which means caller expects true or false. It returns a negative value that is not intended to represent either true or false but a detailed error code. THAT IS THE BUG.

If bools don't exist in C then neither does strlen, gahh.