Changeset 562 for trunk/src


Ignore:
Timestamp:
Jun 29, 2021, 10:23:44 PM (3 years ago)
Author:
katerina
Message:

Fix for ticket #450 (compiler warnings) and fixes for tests.

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/dnmalloc.c

    r520 r562  
    165165 *   HAVE_SYS_PARAM_H Define to #include <sys/param.h> (for pagesize)
    166166 *
    167  *   HAVE_MALLOC_H    Define to #include <malloc.h> (for struct mallinfo)
     167 *   HAVE_MALLOC_H    Define to #include <malloc.h> (for struct mallinfo2)
    168168 *
    169169 *   HAVE_FCNTL_H     Define to #include <fcntl.h>
     
    531531#define vALLOc      public_vALLOc
    532532#define pVALLOc     public_pVALLOc
    533 #define mALLINFo    public_mALLINFo
     533#define mALLINFo2   public_mALLINFo2
    534534#define mALLOPt     public_mALLOPt
    535535#define mTRIm       public_mTRIm
     
    547547#define public_vALLOc    dlvalloc
    548548#define public_pVALLOc   dlpvalloc
    549 #define public_mALLINFo  dlmallinfo
     549#define public_mALLINFo2 dlmallinfo2
    550550#define public_mALLOPt   dlmallopt
    551551#define public_mTRIm     dlmalloc_trim
     
    561561#define public_vALLOc    valloc
    562562#define public_pVALLOc   pvalloc
    563 #define public_mALLINFo  mallinfo
     563#define public_mALLINFo2 mallinfo2
    564564#define public_mALLOPt   mallopt
    565565#define public_mTRIm     malloc_trim
     
    791791
    792792/*
    793   This version of malloc supports the standard SVID/XPG mallinfo
     793  This version of malloc supports the standard SVID/XPG mallinfo2
    794794  routine that returns a struct containing usage properties and
    795795  statistics. It should work on any SVID/XPG compliant system that has
    796   a /usr/include/malloc.h defining struct mallinfo. (If you'd like to
     796  a /usr/include/malloc.h defining struct mallinfo2. (If you'd like to
    797797  install such a thing yourself, cut out the preliminary declarations
    798798  as described above and below and save them in a malloc.h file. But
    799799  there's no compelling reason to bother to do this.)
    800800
    801   The main declaration needed is the mallinfo struct that is returned
    802   (by-copy) by mallinfo().  The SVID/XPG malloinfo struct contains a
     801  The main declaration needed is the mallinfo2 struct that is returned
     802  (by-copy) by mallinfo2().  The SVID/XPG malloinfo2 struct contains a
    803803  bunch of fields that are not even meaningful in this version of
    804   malloc.  These fields are are instead filled by mallinfo() with
     804  malloc.  These fields are are instead filled by mallinfo2() with
    805805  other numbers that might be of interest.
    806806
    807807  HAVE_MALLOC_H should be set if you have a
    808808  /usr/include/malloc.h file that includes a declaration of struct
    809   mallinfo.  If so, it is included; else an SVID2/XPG2 compliant
     809  mallinfo2.  If so, it is included; else an SVID2/XPG2 compliant
    810810  version is declared below.  These must be precisely the same for
    811   mallinfo() to work.  The original SVID version of this struct,
    812   defined on most systems with mallinfo, declares all fields as
    813   ints. But some others define as unsigned long. If your system
     811  mallinfo2() to work.  The original SVID version of this struct,
     812  defined on most systems with mallinfo2, declares all fields as
     813  size_2. But some others define as unsigned long. If your system
    814814  defines the fields using a type of different width than listed here,
    815815  you must #include your system version and #define
     
    826826#else
    827827
    828 /* SVID2/XPG mallinfo structure */
    829 
    830 struct mallinfo {
    831   int arena;    /* non-mmapped space allocated from system */
    832   int ordblks;  /* number of free chunks */
    833   int smblks;   /* number of fastbin blocks */
    834   int hblks;    /* number of mmapped regions */
    835   int hblkhd;   /* space in mmapped regions */
    836   int usmblks;  /* maximum total allocated space */
    837   int fsmblks;  /* space available in freed fastbin blocks */
    838   int uordblks; /* total allocated space */
    839   int fordblks; /* total free space */
    840   int keepcost; /* top-most, releasable (via malloc_trim) space */
     828/* SVID2/XPG mallinfo2 structure */
     829
     830struct mallinfo2 {
     831  size_t arena;    /* non-mmapped space allocated from system */
     832  size_t ordblks;  /* number of free chunks */
     833  size_t smblks;   /* number of fastbin blocks */
     834  size_t hblks;    /* number of mmapped regions */
     835  size_t hblkhd;   /* space in mmapped regions */
     836  size_t usmblks;  /* maximum total allocated space */
     837  size_t fsmblks;  /* space available in freed fastbin blocks */
     838  size_t uordblks; /* total allocated space */
     839  size_t fordblks; /* total free space */
     840  size_t keepcost; /* top-most, releasable (via malloc_trim) space */
    841841};
    842842
     
    10081008
    10091009/*
    1010   mallinfo()
     1010  mallinfo2()
    10111011  Returns (by copy) a struct containing various summary statistics:
    10121012
     
    10311031*/
    10321032#if __STD_C
    1033 struct mallinfo public_mALLINFo(void);
    1034 #else
    1035 struct mallinfo public_mALLINFo();
     1033struct mallinfo2 public_mALLINFo2(void);
     1034#else
     1035struct mallinfo2 public_mALLINFo2();
    10361036#endif
    10371037
     
    11151115
    11161116  malloc_stats prints only the most commonly interesting statistics.
    1117   More information can be obtained by calling mallinfo.
     1117  More information can be obtained by calling mallinfo2.
    11181118
    11191119*/
     
    13661366static void     mSTATs();
    13671367static int      mALLOPt(int, int);
    1368 static struct mallinfo mALLINFo(void);
     1368static struct mallinfo2 mALLINFo2(void);
    13691369#else
    13701370static Void_t*  mALLOc();
     
    13801380static void     mSTATs();
    13811381static int      mALLOPt();
    1382 static struct mallinfo mALLINFo();
     1382static struct mallinfo2 mALLINFo2();
    13831383#endif
    13841384
     
    16871687}
    16881688
    1689 struct mallinfo public_mALLINFo() {
    1690   struct mallinfo m;
     1689struct mallinfo2 public_mALLINFo2() {
     1690  struct mallinfo2 m;
    16911691  if (MALLOC_PREACTION == 0) {
    1692     m = mALLINFo();
     1692    m = mALLINFo2();
    16931693    (void) MALLOC_POSTACTION;
    16941694    return m;
    16951695  } else {
    1696     struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     1696    struct mallinfo2 nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    16971697    return nm;
    16981698  }
     
    52935293*/
    52945294
    5295 DL_STATIC struct mallinfo mALLINFo()
     5295DL_STATIC struct mallinfo2 mALLINFo2()
    52965296{
    52975297  mstate av = get_malloc_state();
    5298   static struct mallinfo mi;
     5298  static struct mallinfo2 mi;
    52995299  unsigned int i;
    53005300  mbinptr b;
     
    53615361DL_STATIC void mSTATs()
    53625362{
    5363   struct mallinfo mi = mALLINFo();
     5363  struct mallinfo2 mi = mALLINFo2();
    53645364
    53655365  fprintf(stderr, "hashtable = %10lu MB\n",
  • trunk/src/sh_login_track.c

    r541 r562  
    402402  while(u)
    403403    {
    404       if (0 == strcmp(user, u->user))
     404      if (0 == sl_strcmp(user, u->user))
    405405        {
    406406          return u;
     
    839839  else
    840840    {
    841       q = strchr(host, '.');
     841      char * tmp = sh_util_strdup(host);
     842      q = strchr(tmp, '.');
    842843      if (q && *q)
    843844        {
    844845          ++q;
    845846          p = sh_util_strdup(q);
     847          SH_FREE(tmp);
    846848        }
    847849      else
    848850        {
    849           p = sh_util_strdup(host);
     851          p = tmp;
    850852        }
    851853    }
  • trunk/src/sh_tools.c

    r550 r562  
    13861386}
    13871387
     1388#ifdef SH_ENCRYPT
    13881389static int probe_ok(int flag)
    13891390{
     
    13931394  return S_FALSE;
    13941395}
     1396#endif
    13951397
    13961398static unsigned char probe_header_set(unsigned char protocol)
     
    14441446}
    14451447
     1448#ifdef SH_ENCRYPT
    14461449static int probe_ok(int flag)
    14471450{
     
    14501453  return S_FALSE;
    14511454}
     1455#endif
     1456
    14521457#endif
    14531458
  • trunk/src/t-test0.c

    r541 r562  
    390390                actions = RANDOM(&ld, ACTIONS_MAX);
    391391#if USE_MALLOC && MALLOC_DEBUG
    392                 if(actions < 2) { mallinfo(); }
     392                if(actions < 2) { mallinfo2(); }
    393393#endif
    394394                for(j=0; j<actions; j++) {
  • trunk/src/t-test1.c

    r481 r562  
    499499                actions = RANDOM(&ld, ACTIONS_MAX);
    500500#if USE_MALLOC && MALLOC_DEBUG
    501                 if(actions < 2) { mallinfo(); }
     501                if(actions < 2) { mallinfo2(); }
    502502#endif
    503503                for(j=0; j<actions; j++) {
  • trunk/src/yulectl.c

    r481 r562  
    4848#endif
    4949
     50#define SH_PW_SIZE 15
     51
    5052static int    sock     = -1;
    51 static char   password[15] = "";
     53static char   password[SH_PW_SIZE] = "";
    5254static int    verbose = 0;
    5355
     
    123125static char * safe_copy(char * to, const char * from, size_t size)
    124126{
    125   if (to && from)
    126     {
    127       strncpy (to, from, size);
    128       if (size > 0)
    129         to[size-1] = '\0';
    130       else
    131         *to = '\0';
     127  if (to && from && (size > 0))
     128    {
     129      strncpy (to, from, size-1);
     130      to[size-1] = '\0';
    132131    }
    133132  return to;
     
    144143   */
    145144  name.sun_family = AF_UNIX;
    146   strncpy (name.sun_path, serversock, sizeof(name.sun_path) - 1);
     145  memcpy(name.sun_path, serversock, sizeof(name.sun_path));
     146  name.sun_path[sizeof(name.sun_path)-1] = '\0';
     147  if (strlen(serversock) > strlen(name.sun_path))
     148    {
     149      perror (_("ERROR: socket path too long"));
     150      return -1;
     151    }
    147152  size = (offsetof (struct sockaddr_un, sun_path)
    148153          + strlen (name.sun_path) + 1);
     
    401406   */
    402407  pw = getenv(_("YULECTL_PASSWORD"));
    403   if (pw && strlen(pw) < 15)
     408  if (pw && strlen(pw) < SH_PW_SIZE)
    404409    {
    405410      strcpy(password, pw);
     
    413418    return -1;
    414419
    415   if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > 4096)
     420  if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > sizeof(home))
    416421    {
    417422      fprintf (stderr, "%s", _("ERROR: path for $HOME is too long.\n"));
     
    451456  (void) rtrim(message2);
    452457
    453   if (strlen(message2) > 14)
     458  if (strlen(message2) > (SH_PW_SIZE -1))
    454459    {
    455460      fprintf (stderr, "%s",
Note: See TracChangeset for help on using the changeset viewer.