More signed/unsigned fixes (yes, I run with funny compiler options) and
authorAndrew Bartlett <abartlet@samba.org>
Sat, 22 Feb 2003 12:22:06 +0000 (12:22 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 22 Feb 2003 12:22:06 +0000 (12:22 +0000)
make x_fwrite() match fwrite() in returning a size_t.

Andrew Bartlett

source/include/hash.h
source/lib/hash.c
source/lib/pidfile.c
source/lib/time.c
source/lib/util_file.c
source/lib/util_seaccess.c
source/lib/xfile.c
source/smbd/dosmode.c
source/smbd/mangle_hash2.c

index c327c971ab8186d84a1f6c5ebfb4f0301f4f3d70..40cc8b7cab3a91d5bd8539b8daed6235a576f4df 100644 (file)
@@ -66,8 +66,8 @@ typedef struct hash_element {
 typedef struct hash_table {
         ubi_dlList      *buckets;
         ubi_dlList      lru_chain;     
-        int     num_elements;  
-        int     size;
+        unsigned     num_elements;     
+        unsigned     size;
         compare_function        comp_func; 
 } hash_table;
 
index 6b7a8476b1794c18f0fcc83f0b042d45879c959d..95af4857079005f9155e9d240f5963a82b0f492b 100644 (file)
@@ -28,7 +28,7 @@
 #include "includes.h"
 
 static BOOL enlarge_hash_table(hash_table *table);
-static int primes[] = 
+static unsigned primes[] = 
         {17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 16411};
 
 /****************************************************************************
@@ -47,9 +47,9 @@ static int primes[] =
  ****************************************************************************
  */
 
-BOOL hash_table_init(hash_table *table, int num_buckets, compare_function compare_func)
+BOOL hash_table_init(hash_table *table, unsigned num_buckets, compare_function compare_func)
 {
-       int     i;
+       unsigned        i;
        ubi_dlList      *bucket;
 
        table->num_elements = 0;
@@ -118,7 +118,7 @@ static hash_element *hash_chain_find(hash_table *table, ubi_dlList *hash_chain,
 {
        hash_element *hash_elem;
        ubi_dlNodePtr lru_item;
-       int     i = 0;
+       unsigned int    i = 0;
 
        for (hash_elem = (hash_element *)(ubi_dlFirst(hash_chain)); i < hash_chain->count; 
                i++, hash_elem = (hash_element *)(ubi_dlNext(hash_elem))) {
@@ -299,7 +299,7 @@ static BOOL enlarge_hash_table(hash_table *table)
 
 void hash_clear(hash_table *table)
 {
-       int i;
+       unsigned int i;
        ubi_dlList      *bucket = table->buckets;
        hash_element    *hash_elem;
        for (i = 0; i < table->size; bucket++, i++) {
index 16a12656b3a72da2edf95a2e3519286a2fe873e6..1a462bf12876a53db13d47ba69945728bf774274 100644 (file)
@@ -100,7 +100,7 @@ void pidfile_create(const char *name)
 
        memset(buf, 0, sizeof(buf));
        slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) sys_getpid());
-       if (write(fd, buf, strlen(buf)) != strlen(buf)) {
+       if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
                DEBUG(0,("ERROR: can't write to file %s: %s\n", 
                         pidFile, strerror(errno)));
                exit(1);
index ea5c6837bf19e367d65a025dae9dfa908c9a9d72..f76a1bdc0d89029c3db7896d46088e958d62dff1 100644 (file)
@@ -479,7 +479,7 @@ check if it's a null mtime
 ****************************************************************************/
 BOOL null_mtime(time_t mtime)
 {
-  if (mtime == 0 || mtime == 0xFFFFFFFF || mtime == (time_t)-1)
+  if (mtime == 0 || mtime == (time_t)0xFFFFFFFF || mtime == (time_t)-1)
     return(True);
   return(False);
 }
index 4babab89310f23f076ca812c9b3c616466b4c9bc..02acbd4d7e1c2c1d569cb86631a557ae4df66a1a 100644 (file)
@@ -593,7 +593,7 @@ BOOL file_save(const char *fname, void *packet, size_t length)
        if (fd == -1) {
                return False;
        }
-       if (write(fd, packet, length) != length) {
+       if (write(fd, packet, length) != (size_t)length) {
                return False;
        }
        close(fd);
index 21d7fe85995dbe28b3b10675147ee11b37011eae..eba8cab7fb82734911713df2c4fe1ecda31bef33 100644 (file)
@@ -343,7 +343,7 @@ SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr,
        SEC_DESC *sd;
        SEC_ACL *new_dacl, *the_acl;
        SEC_ACE *new_ace_list = NULL;
-       int new_ace_list_ndx = 0, i;
+       unsigned int new_ace_list_ndx = 0, i;
        size_t size;
 
        /* Currently we only process the dacl when creating the child.  The
index 57f3e2763898fa16725c8efe0bc714b977330b85..1534dd855e9e2b72202231e5382a1bcd03f3b1fe 100644 (file)
@@ -140,9 +140,10 @@ int x_fclose(XFILE *f)
 }
 
 /* simulate fwrite() */
-int x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
+size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
 {
-       int ret, total=0;
+       ssize_t ret;
+       size_t total=0;
 
        /* we might be writing unbuffered */
        if (f->buftype == X_IONBF || 
@@ -154,7 +155,7 @@ int x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
 
 
        while (total < size*nmemb) {
-               int n = f->bufsize - f->bufused;
+               size_t n = f->bufsize - f->bufused;
                n = MIN(n, (size*nmemb)-total);
 
                if (n == 0) {
index 77d8c9cc920ffcf64e06c8dd3ede4d46f919ac6f..6c21dc04d0fba305ea4ababe7a65ab6ac4bc12d4 100644 (file)
@@ -181,7 +181,7 @@ uint32 dos_mode(connection_struct *conn,char *path,SMB_STRUCT_STAT *sbuf)
 /*******************************************************************
 chmod a file - but preserve some bits
 ********************************************************************/
-int file_chmod(connection_struct *conn,char *fname,int dosmode,SMB_STRUCT_STAT *st)
+int file_chmod(connection_struct *conn,char *fname, uint32 dosmode,SMB_STRUCT_STAT *st)
 {
        SMB_STRUCT_STAT st1;
        int mask=0;
index bbc9020eabc78b04fa008fa63fecf012a194b82f..eda509214d8a63090537cdf87d6c8f1a4be6e7e2 100644 (file)
@@ -203,7 +203,7 @@ static const char *cache_lookup(u32 hash)
  */
 static BOOL is_mangled_component(const char *name)
 {
-       int len, i;
+       unsigned int len, i;
 
        M_DEBUG(10,("is_mangled_component %s ?\n", name));
 
@@ -368,7 +368,7 @@ static void mangle_reset(void)
 static BOOL check_cache(char *name)
 {
        u32 hash, multiplier;
-       int i;
+       unsigned int i;
        const char *prefix;
        char extension[4];
 
@@ -489,8 +489,8 @@ static void name_map(char *name, BOOL need83, BOOL cache83)
        char *dot_p;
        char lead_chars[7];
        char extension[4];
-       int extension_length, i;
-       int prefix_len;
+       unsigned int extension_length, i;
+       unsigned int prefix_len;
        u32 hash, v;
        char new_name[13];