Subject: Re: libssh2 master c28fa65 bugfix: avoid using the socket if it failed to create one

Re: libssh2 master c28fa65 bugfix: avoid using the socket if it failed to create one

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 27 Apr 2010 19:51:17 +0200 (CEST)

On Tue, 27 Apr 2010, Peter Stuge wrote:

>> + if(-1 == sock) {
>> + fprintf(stderr, "failed to create socket!\n");
>> + return -1;
>> + }
>
> Maybe
>
> #ifdef WIN32
> if (INVALID_SOCKET == sock) {
> #else
> if (-1 == sock) {
> #endif
>
> but it's kinda ugly.

Right, it might be nicer to have a section at the top like:

#ifndef INVALID_SOCKET
#define INVALID_SOCKET -1
#define

and then use this unconditionally:

if (INVALID_SOCKET == sock)

The boring part is that we should probably try to do this uniformly in all
examples, and there are 18 of them! ;-O

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-04-27