Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/hunt/huntd simplify silly logic



details:   https://anonhg.NetBSD.org/src/rev/d2bddedbbefe
branches:  trunk
changeset: 328220:d2bddedbbefe
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Mar 29 19:01:00 2014 +0000

description:
simplify silly logic

diffstat:

 games/hunt/huntd/get_names.c |  25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diffs (58 lines):

diff -r 241c8afd0124 -r d2bddedbbefe games/hunt/huntd/get_names.c
--- a/games/hunt/huntd/get_names.c      Sat Mar 29 18:54:36 2014 +0000
+++ b/games/hunt/huntd/get_names.c      Sat Mar 29 19:01:00 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: get_names.c,v 1.11 2014/03/28 17:49:11 apb Exp $       */
+/*     $NetBSD: get_names.c,v 1.12 2014/03/29 19:01:00 dholland Exp $  */
 /*
  * Copyright (c) 1983-2003, Regents of the University of California.
  * All rights reserved.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: get_names.c,v 1.11 2014/03/28 17:49:11 apb Exp $");
+__RCSID("$NetBSD: get_names.c,v 1.12 2014/03/29 19:01:00 dholland Exp $");
 #endif /* not lint */
 
 #include "bsd.h"
@@ -126,6 +126,7 @@
                /* this is a local to local talk */
                his_name = his_address;
                his_machine_name = my_machine_name;
+               his_machine_addr = my_machine_addr;
        } else {
                if (*ptr == '@') {
                        /* user@host */
@@ -137,23 +138,19 @@
                        his_machine_name = his_address;
                }
                *ptr = '\0';
+
+               /* look up the address of the recipient's machine */
+               hp = gethostbyname(his_machine_name);
+               if (hp == NULL) {
+                       /* unknown host */
+                       return 0;
+               }
+               memcpy(&his_machine_addr, hp->h_addr, hp->h_length);
        }
        /* Load these useful values into the standard message header */
        (void) strncpy(msg.r_name, his_name, NAME_SIZE);
        msg.r_name[NAME_SIZE - 1] = '\0';
 
-       /* if he is on the same machine, then simply copy */
-       if (memcmp(&his_machine_name, &my_machine_name,
-                                               sizeof(his_machine_name)) == 0)
-               memcpy(&his_machine_addr, &my_machine_addr,
-                                               sizeof(his_machine_addr));
-       else {
-               /* look up the address of the recipient's machine */
-               hp = gethostbyname(his_machine_name);
-               if (hp == (struct hostent *) 0)
-                       return 0;                       /* unknown host */
-               memcpy(&his_machine_addr, hp->h_addr, hp->h_length);
-       }
        return 1;
 }
 #endif



Home | Main Index | Thread Index | Old Index