Print this page
10125 smatch fixes for cmd-inet


  21  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  22  * Use is subject to license terms.
  23  */
  24 
  25 /*
  26  * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T
  27  * All Rights Reserved.
  28  */
  29 
  30 /*
  31  * University Copyright- Copyright (c) 1982, 1986, 1988
  32  * The Regents of the University of California.
  33  * All Rights Reserved.
  34  *
  35  * University Acknowledgment- Portions of this document are derived from
  36  * software developed by the University of California, Berkeley, and its
  37  * contributors.
  38  */
  39 
  40 /*
  41  * Copyright (c) 2017, Joyent, Inc.
  42  */
  43 
  44 #include <assert.h>
  45 #include <stdio.h>
  46 #include <strings.h>
  47 #include <errno.h>
  48 #include <fcntl.h>
  49 #include <unistd.h>
  50 #include <signal.h>
  51 #include <limits.h>
  52 #include <math.h>
  53 #include <locale.h>
  54 #include <thread.h>
  55 #include <synch.h>
  56 
  57 #include <sys/time.h>
  58 #include <sys/param.h>
  59 #include <sys/socket.h>
  60 #include <sys/sockio.h>
  61 #include <sys/stropts.h>


1972                                                 Fprintf(stderr,
1973                                                     "%s: recvmsg %s\n",
1974                                                     progname, strerror(errno));
1975                                         }
1976                                         continue;
1977                                 } else if (cc > 0) {
1978                                         check_reply6(ai_dst, &in_msg, cc,
1979                                             udp_src_port6);
1980                                 }
1981                         }
1982                         /* Do we have an ICMP packet waiting? */
1983                         if ((recv_sock != -1) && (FD_ISSET(recv_sock, &fds))) {
1984                                 cc = recvmsg(recv_sock, &in_msg, 0);
1985                                 if (cc < 0) {
1986                                         if (errno != EINTR) {
1987                                                 Fprintf(stderr,
1988                                                     "%s: recvmsg %s\n",
1989                                                     progname, strerror(errno));
1990                                         }
1991                                         continue;
1992                                 } if (cc > 0) {
1993                                         check_reply(ai_dst, &in_msg, cc,
1994                                             udp_src_port);
1995                                 }
1996                         }
1997                 }
1998                 /*
1999                  * If we were probing last IP address of the target host and
2000                  * received a reply for each probe sent to this address,
2001                  * then we are done!
2002                  */
2003                 if ((npackets > 0) && (current_targetaddr->next == NULL) &&
2004                     (nreceived_last_target == npackets)) {
2005                         timer_done = _B_TRUE;
2006                         finish();
2007                 }
2008         } /* infinite loop */
2009 }
2010 
2011 /*
2012  * Given a host (with possibly multiple IP addresses) and an IP address, this




  21  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  22  * Use is subject to license terms.
  23  */
  24 
  25 /*
  26  * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T
  27  * All Rights Reserved.
  28  */
  29 
  30 /*
  31  * University Copyright- Copyright (c) 1982, 1986, 1988
  32  * The Regents of the University of California.
  33  * All Rights Reserved.
  34  *
  35  * University Acknowledgment- Portions of this document are derived from
  36  * software developed by the University of California, Berkeley, and its
  37  * contributors.
  38  */
  39 
  40 /*
  41  * Copyright (c) 2018, Joyent, Inc.
  42  */
  43 
  44 #include <assert.h>
  45 #include <stdio.h>
  46 #include <strings.h>
  47 #include <errno.h>
  48 #include <fcntl.h>
  49 #include <unistd.h>
  50 #include <signal.h>
  51 #include <limits.h>
  52 #include <math.h>
  53 #include <locale.h>
  54 #include <thread.h>
  55 #include <synch.h>
  56 
  57 #include <sys/time.h>
  58 #include <sys/param.h>
  59 #include <sys/socket.h>
  60 #include <sys/sockio.h>
  61 #include <sys/stropts.h>


1972                                                 Fprintf(stderr,
1973                                                     "%s: recvmsg %s\n",
1974                                                     progname, strerror(errno));
1975                                         }
1976                                         continue;
1977                                 } else if (cc > 0) {
1978                                         check_reply6(ai_dst, &in_msg, cc,
1979                                             udp_src_port6);
1980                                 }
1981                         }
1982                         /* Do we have an ICMP packet waiting? */
1983                         if ((recv_sock != -1) && (FD_ISSET(recv_sock, &fds))) {
1984                                 cc = recvmsg(recv_sock, &in_msg, 0);
1985                                 if (cc < 0) {
1986                                         if (errno != EINTR) {
1987                                                 Fprintf(stderr,
1988                                                     "%s: recvmsg %s\n",
1989                                                     progname, strerror(errno));
1990                                         }
1991                                         continue;
1992                                 } else if (cc > 0) {
1993                                         check_reply(ai_dst, &in_msg, cc,
1994                                             udp_src_port);
1995                                 }
1996                         }
1997                 }
1998                 /*
1999                  * If we were probing last IP address of the target host and
2000                  * received a reply for each probe sent to this address,
2001                  * then we are done!
2002                  */
2003                 if ((npackets > 0) && (current_targetaddr->next == NULL) &&
2004                     (nreceived_last_target == npackets)) {
2005                         timer_done = _B_TRUE;
2006                         finish();
2007                 }
2008         } /* infinite loop */
2009 }
2010 
2011 /*
2012  * Given a host (with possibly multiple IP addresses) and an IP address, this