Ignore:
Timestamp:
Apr 30, 2008, 11:56:45 PM (17 years ago)
Author:
katerina
Message:

Plenty of compiler warnings fixed, SQL query length fixed, doc update.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_portcheck.c

    r169 r170  
    179179    }
    180180
    181   val = (val <= 0 ? 60 : val);
    182 
    183181  sh_portchk_interval = (time_t) val;
    184182  SL_RETURN(0, _("sh_portchk_set_interval"));
     
    251249/* Interface to initialize port check
    252250 */
    253 int sh_portchk_init ();
     251int sh_portchk_init (struct mod_type * arg);
    254252
    255253/* Interface to reset port check
    256254 */
    257 int sh_portchk_reset ();
     255int sh_portchk_reset (void);
    258256
    259257/* Interface to run port check
    260258 */
    261 int sh_portchk_check ();
     259int sh_portchk_check (void);
    262260
    263261
     
    317315 * Thereafter, we check for entries that are still UNKN.
    318316 */
    319 static void sh_portchk_reset_lists ()
     317static void sh_portchk_reset_lists (void)
    320318{
    321319  struct sh_portentry * portlist;
     
    364362}
    365363 
     364/* These variables are not used anywhere. They only exist
     365 * to assign &pre, &ptr to them, which keeps gcc from
     366 * putting it into a register, and avoids the 'clobbered
     367 * by longjmp' warning. And no, 'volatile' proved insufficient.
     368 */
     369static void * sh_dummy_pre = NULL;
     370static void * sh_dummy_ptr = NULL;
     371
    366372/* check the list of open ports for any that are marked as UNKN
    367373 */
     
    372378  char errbuf[256];
    373379
     380  /* Take the address to keep gcc from putting them into registers.
     381   * Avoids the 'clobbered by longjmp' warning.
     382   */
     383  sh_dummy_pre = (void*) &pre;
     384  sh_dummy_ptr = (void*) &ptr;
     385 
    374386  while (ptr)
    375387    {
     
    817829          flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0);
    818830          retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK);
    819           write (fd, _("SSH-2.0-Foobar"), 14);
    820           write (fd, "\r\n", 2);
     831          retval = write (fd, _("SSH-2.0-Foobar"), 14);
     832          if (retval > 0) retval = write (fd, "\r\n", 2);
    821833        }
    822834      else if (port == 25)  /* smtp */
     
    824836          flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0);
    825837          retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK);
    826           write (fd, _("QUIT"), 4);
    827           write (fd, "\r\n", 2);
     838          retval = write (fd, _("QUIT"), 4);
     839          if (retval > 0) retval = write (fd, "\r\n", 2);
    828840        }
    829841      else if (port == 79)  /* finger */
     
    831843          flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0);
    832844          retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK);
    833           write (fd, "\r\n", 2);
     845          retval = write (fd, "\r\n", 2);
    834846        }
    835847      else if (port == 110) /* pop3 */
     
    837849          flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0);
    838850          retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK);
    839           write (fd, _("QUIT"), 4);
    840           write (fd, "\r\n", 2);
     851          retval = write (fd, _("QUIT"), 4);
     852          if (retval > 0) retval = write (fd, "\r\n", 2);
    841853        }
    842854      else if (port == 143) /* imap */
     
    844856          flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0);
    845857          retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK);
    846           write (fd, _("A01 LOGOUT"), 10);
    847           write (fd, "\r\n", 2);
    848         }
     858          retval = write (fd, _("A01 LOGOUT"), 10);
     859          if (retval > 0) retval = write (fd, "\r\n", 2);
     860        }
     861
     862      if (portchk_debug && retval < 0)
     863        fprintf(stderr, _("check port: error writing to port %5d\n"),
     864                port);
    849865     }
    850866  close (fd);
     
    878894{
    879895  struct hostent * hent;
    880   int              i = 0;
     896  volatile int     i; /* might be clobbered by ‘longjmp’ or ‘vfork’*/
    881897  char errbuf[256];
    882898
     
    899915  SH_MUTEX_LOCK(mutex_resolv);
    900916  hent = sh_gethostbyname(portchk_hostname);
    901 
     917  i = 0;
    902918  while (hent && hent->h_addr_list[i] && (iface_list.used < SH_IFACE_MAX))
    903919    {
     
    945961
    946962#if !defined(TEST_ONLY)
    947 int sh_portchk_reconf ()
     963int sh_portchk_reconf (void)
    948964{
    949965  SH_MUTEX_LOCK(mutex_port_check);
     
    962978}
    963979
    964 int sh_portchk_cleanup ()
     980int sh_portchk_cleanup (void)
    965981{
    966982  return sh_portchk_reconf ();
     
    983999static int check_port_generic (int port, int type, int protocol)
    9841000{
    985   int              i    =  0;
     1001  volatile int     i    =  0;
    9861002  int              sock = -1;
    9871003  int              flag =  1; /* non-zero to enable an option */
     
    10021018      if ((sock = socket(AF_INET, type, protocol)) < 0 )
    10031019        {
     1020          ++i;
    10041021#ifdef TEST_ONLY
    10051022          if (portchk_debug)
     
    10101027                          sh_error_message(errno, errbuf, sizeof(errbuf)), _("socket"));
    10111028          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    1012           ++i;
     1029#endif
    10131030          continue;
    1014 #endif
    10151031        }
    10161032      if ( setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
    10171033                      (void *) &flag, sizeof(flag)) < 0 )
    10181034        {
     1035          ++i;
    10191036#ifdef TEST_ONLY
    10201037          if (portchk_debug)
     
    10261043          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    10271044#endif
    1028           ++i;
    10291045          continue;
    10301046        }
     
    10561072
    10571073
    1058 static int sh_portchk_scan_ports_generic (int min_port, int max_port, int type, int protocol)
     1074static int sh_portchk_scan_ports_generic (int min_port, int max_port_arg, int type, int protocol)
    10591075{
    10601076  /*
     
    10631079  */
    10641080
    1065   int port;
     1081  volatile int port; /*  might be clobbered by ‘longjmp’ or ‘vfork’*/
     1082  volatile int max_port = max_port_arg;
    10661083  int retval;
    10671084  int sock   = -1;
     
    14441461int sh_portchk_check ()
    14451462{
    1446   int min_port = 0;
     1463  volatile int min_port;
    14471464
    14481465  SH_MUTEX_LOCK(mutex_port_check);
     1466
     1467  min_port = 0;
     1468
    14491469  if (sh_portchk_active != S_FALSE)
    14501470    {
Note: See TracChangeset for help on using the changeset viewer.