On Fri,  1 Jun 2012 21:31:17 +0200
Niklas Söderlund <[email protected]> wrote:

> Replace with return statements and adopt the only upstream caller which
> in turn all plumbing is place for
> 
> Signed-off-by: Niklas Söderlund <[email protected]>
> ---
>  serprog.c |   19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/serprog.c b/serprog.c
> index d06fb0b..02996ea 100644
> --- a/serprog.c
> +++ b/serprog.c
> @@ -110,20 +110,25 @@ static int sp_opensocket(char *ip, unsigned int port)
>       int sock;
>       msg_pdbg(MSGHEADER "IP %s port %d\n", ip, port);
>       sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
> -     if (sock < 0)
> -             sp_die("Error: serprog cannot open socket");
> +     if (sock < 0) {
> +             msg_perr("Error: serprog cannot open socket: %s\n", 
> strerror(errno));
> +             return -1;
> +     }
>       hostPtr = gethostbyname(ip);
>       if (NULL == hostPtr) {
>               hostPtr = gethostbyaddr(ip, strlen(ip), AF_INET);
> -             if (NULL == hostPtr)
> -                     sp_die("Error: cannot resolve");
> +             if (NULL == hostPtr) {
> +                     msg_perr("Error: cannot resolve: %s\n", 
> strerror(errno));

i changed this to
        msg_perr("Error: cannot resolve %s\n", ip);
because errno is not set correctly by gethostbyaddr (which is obsolete
and should be replaced anyway).

> +                     return -1;
> +             }
>       }
>       sp.si.sin_family = AF_INET;
>       sp.si.sin_port = htons(port);
>       (void)memcpy(&sp.si.sin_addr, hostPtr->h_addr, hostPtr->h_length);

btw: this does explode spectacularly (not your fault, niklas, of
course).

i think i kept the rest as is.
thanks, niklas! applied in r1557.

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to