I was reading some functions in socket.c (0.4.30), and I have some questions, only little details w/o much importance

cherokee_read():
        line 732:
                if (unlikely (buf == NULL)) {
                        char tmp[buf_size+1];
                        len = gnutls_record_recv (socket->session, tmp, 
buf_size);
                } else {

char tmp[buf_size+1] is C99, not ANSI C and gcc implements it using alloca(3). The manual page says it is not recommendable to use alloca. I suggest:

                if (unlikely (buf == NULL)) {
                        char *tmp=malloc(buf_size+1);
                        if(!tmp)
                                return ret_error;
                        len = gnutls_record_recv (socket->session, tmp, 
buf_size);
                        free(tmp);
                } else {

or something similar

        line 753:
                *done=0;
Well, in line 833: if(done!=NULL) *done=len; So, I think we would check *done!=NULL in every assigment (or never check it) I have seen a lot of *done=0; But in some cases (e.g. socket->is_tls==TLS and len== GNUTLS_E_AGAIN) no assignment is made. I suggest a *done=0; with check in the beginning of cherokee_read and remove the others *done=0;
        (in cherokee_writev the same but with written)

        line 789: goto out; I Would do:

        if(TLS==socket->is_tls) {
                /*[...] (w/o goto)*/
        } else {
                /*Plain read
                */
                /*[...]*/
        }

        if(done)
                *done=len;

        return ret_ok;

        and remove the goto
_______________________________________________
Cherokee mailing list
[email protected]
http://www.alobbs.com/cgi-bin/mailman/listinfo/cherokee

Reply via email to