simple wake.c diff

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

simple wake.c diff

Thomas Jeunet
Hello,

Here is a simple readability diff with no functional changes for the
new tool "wake"

Regards,
--
Thomas Jeunet


Index: usr.sbin/wake/wake.c
===================================================================
RCS file: /cvs/openbsd/src/usr.sbin/wake/wake.c,v
retrieving revision 1.11
diff -u -r1.11 wake.c
--- usr.sbin/wake/wake.c        29 Jan 2009 15:50:03 -0000      1.11
+++ usr.sbin/wake/wake.c        30 Jan 2009 10:10:02 -0000
@@ -88,10 +88,10 @@
                return -1;
        if (bind_if_to_bpf(iface, bpf) == -1 ||
            get_ether(host, &macaddr) == -1) {
-               (void)close(bpf);
-               return -1;
+               res = -1;
+       } else {
+               res = send_wakeup(bpf, &macaddr);
        }
-       res = send_wakeup(bpf, &macaddr);
        (void)close(bpf);
        return res;
 }

Reply | Threaded
Open this post in threaded view
|

Re: simple wake.c diff

Marc Balmer-2
* Thomas Jeunet wrote:
> Hello,
>
> Here is a simple readability diff with no functional changes for the
> new tool "wake"

no.  this is purely stilistic and then I don't like curly braces
around single statements.

>
> Regards,
> --
> Thomas Jeunet
>
>
> Index: usr.sbin/wake/wake.c
> ===================================================================
> RCS file: /cvs/openbsd/src/usr.sbin/wake/wake.c,v
> retrieving revision 1.11
> diff -u -r1.11 wake.c
> --- usr.sbin/wake/wake.c        29 Jan 2009 15:50:03 -0000      1.11
> +++ usr.sbin/wake/wake.c        30 Jan 2009 10:10:02 -0000
> @@ -88,10 +88,10 @@
>                 return -1;
>         if (bind_if_to_bpf(iface, bpf) == -1 ||
>             get_ether(host, &macaddr) == -1) {
> -               (void)close(bpf);
> -               return -1;
> +               res = -1;
> +       } else {
> +               res = send_wakeup(bpf, &macaddr);
>         }
> -       res = send_wakeup(bpf, &macaddr);
>         (void)close(bpf);
>         return res;
>  }
>
--
Marc Balmer, Micro Systems, Wiesendamm 2a, Postfach, CH-4019 Basel, Switzerland
http://www.msys.ch/     http://www.vnode.ch/   "In God we trust, in C we code."

Reply | Threaded
Open this post in threaded view
|

Re: simple wake.c diff

Thomas Jeunet
On Fri, Jan 30, 2009 at 11:37 AM, Marc Balmer <[hidden email]> wrote:
> * Thomas Jeunet wrote:
>> Hello,
>>
>> Here is a simple readability diff with no functional changes for the
>> new tool "wake"
>
> no.  this is purely stilistic and then I don't like curly braces
> around single statements.
>
[...]

I modified it to remove the curly braces around single statements then.

Index: wake.c
===================================================================
RCS file: /cvs/openbsd/src/usr.sbin/wake/wake.c,v
retrieving revision 1.11
diff -u -r1.11 wake.c
--- wake.c      29 Jan 2009 15:50:03 -0000      1.11
+++ wake.c      30 Jan 2009 10:53:53 -0000
@@ -86,12 +86,13 @@
        bpf = get_bpf();
        if (bpf == -1)
                return -1;
+
        if (bind_if_to_bpf(iface, bpf) == -1 ||
-           get_ether(host, &macaddr) == -1) {
-               (void)close(bpf);
-               return -1;
-       }
-       res = send_wakeup(bpf, &macaddr);
+           get_ether(host, &macaddr) == -1)
+               res = -1;
+       else
+               res = send_wakeup(bpf, &macaddr);
+
        (void)close(bpf);
        return res;
 }

Reply | Threaded
Open this post in threaded view
|

Re: simple wake.c diff

Marc Balmer-2
* Thomas Jeunet wrote:

> On Fri, Jan 30, 2009 at 11:37 AM, Marc Balmer <[hidden email]> wrote:
> > * Thomas Jeunet wrote:
> >> Hello,
> >>
> >> Here is a simple readability diff with no functional changes for the
> >> new tool "wake"
> >
> > no.  this is purely stilistic and then I don't like curly braces
> > around single statements.
> >
> [...]
>
> I modified it to remove the curly braces around single statements then.

sorry, but no.

>
> Index: wake.c
> ===================================================================
> RCS file: /cvs/openbsd/src/usr.sbin/wake/wake.c,v
> retrieving revision 1.11
> diff -u -r1.11 wake.c
> --- wake.c      29 Jan 2009 15:50:03 -0000      1.11
> +++ wake.c      30 Jan 2009 10:53:53 -0000
> @@ -86,12 +86,13 @@
>         bpf = get_bpf();
>         if (bpf == -1)
>                 return -1;
> +
>         if (bind_if_to_bpf(iface, bpf) == -1 ||
> -           get_ether(host, &macaddr) == -1) {
> -               (void)close(bpf);
> -               return -1;
> -       }
> -       res = send_wakeup(bpf, &macaddr);
> +           get_ether(host, &macaddr) == -1)
> +               res = -1;
> +       else
> +               res = send_wakeup(bpf, &macaddr);
> +
>         (void)close(bpf);
>         return res;
>  }
>
--
Marc Balmer, Micro Systems, Wiesendamm 2a, Postfach, CH-4019 Basel, Switzerland
http://www.msys.ch/     http://www.vnode.ch/   "In God we trust, in C we code."