<<< Date Index >>>     <<< Thread Index >>>

Re: sscanf (x, "%u", &(uint64_t))



hello,

> Are you sure, uint32_t could easily be unsigned long.
> In which case you would need %ul in order to remove the compiler
> warnings.

true. So here is the next patch.

        Thomas
diff -Nru a/hcache.c b/hcache.c
--- a/hcache.c  2005-03-16 04:49:33 +01:00
+++ b/hcache.c  2005-03-21 08:12:14 +01:00
@@ -63,7 +63,7 @@
 typedef union
 {
   struct timeval timeval;
-  uint64_t uid_validity;
+  unsigned long uid_validity;
 } validate;
 
 static void *
@@ -550,7 +550,7 @@
  * db_store */
 static void *
 mutt_hcache_dump(void *_db, HEADER * h, int *off,
-                uint64_t uid_validity)
+                unsigned long uid_validity)
 {
   struct header_cache *db = _db;
   unsigned char *d = NULL;
@@ -559,7 +559,7 @@
   d = lazy_malloc(sizeof (validate));
 
   if (uid_validity)
-    memcpy(d, &uid_validity, sizeof (uint64_t));
+    memcpy(d, &uid_validity, sizeof (unsigned long));
   else
   {
     struct timeval now;
@@ -696,7 +696,7 @@
 
 int
 mutt_hcache_store(void *db, const char *filename, HEADER * header,
-                 uint64_t uid_validity,
+                 unsigned long uid_validity,
                  size_t(*keylen) (const char *fn))
 {
   struct header_cache *h = db;
@@ -886,7 +886,7 @@
 
 int
 mutt_hcache_store(void *db, const char *filename, HEADER * header,
-                 uint64_t uid_validity,
+                 unsigned long uid_validity,
                  size_t(*keylen) (const char *fn))
 {
   DBT key;
diff -Nru a/imap/imap.c b/imap/imap.c
--- a/imap/imap.c       2005-02-17 05:33:00 +01:00
+++ b/imap/imap.c       2005-03-21 21:31:35 +01:00
@@ -635,7 +635,7 @@
       dprint(2, (debugfile, "Getting mailbox UIDVALIDITY\n"));
       pc += 3;
       pc = imap_next_word(pc);
-      sscanf(pc, "%u", &(idata->uid_validity));
+      sscanf(pc, "%ul", &(idata->uid_validity));
     }
 #endif
     else
diff -Nru a/imap/imap_private.h b/imap/imap_private.h
--- a/imap/imap_private.h       2005-02-17 05:33:00 +01:00
+++ b/imap/imap_private.h       2005-03-21 08:12:32 +01:00
@@ -180,7 +180,7 @@
   IMAP_CACHE cache[IMAP_CACHE_LEN];
   unsigned int noclose : 1;
 #ifdef USE_HCACHE
-  uint64_t uid_validity;
+  unsigned long uid_validity;
 #endif
   
   /* all folder flags - system flags AND keywords */
diff -Nru a/imap/message.c b/imap/message.c
--- a/imap/message.c    2005-02-27 05:18:23 +01:00
+++ b/imap/message.c    2005-03-21 08:13:01 +01:00
@@ -69,7 +69,7 @@
 
 #if USE_HCACHE
   void *hc   = NULL;
-  uint64_t *uid_validity = NULL;
+  unsigned long *uid_validity = NULL;
   char uid_buf[64];
 #endif /* USE_HCACHE */
 
@@ -154,7 +154,7 @@
       fputs ("\n\n", fp);
 
       sprintf(uid_buf, "/%u", h.data->uid); /* XXX --tg 21:41 04-07-11 */
-      uid_validity = (uint64_t *) mutt_hcache_fetch (hc, uid_buf, 
&imap_hcache_keylen);
+      uid_validity = (unsigned long *) mutt_hcache_fetch (hc, uid_buf, 
&imap_hcache_keylen);
 
       if (uid_validity != NULL
       && *uid_validity == idata->uid_validity) {
diff -Nru a/protos.h b/protos.h
--- a/protos.h  2005-02-01 05:36:39 +01:00
+++ b/protos.h  2005-03-21 08:13:11 +01:00
@@ -111,7 +111,7 @@
 void mutt_hcache_close(void *db);
 HEADER *mutt_hcache_restore(const unsigned char *d, HEADER **oh);
 void *mutt_hcache_fetch(void *db, const char *filename, size_t (*keylen)(const 
char *fn));
-int mutt_hcache_store(void *db, const char *filename, HEADER *h, uint64_t 
uid_validity, size_t (*keylen)(const char *fn));
+int mutt_hcache_store(void *db, const char *filename, HEADER *h, unsigned long 
uid_validity, size_t (*keylen)(const char *fn));
 int mutt_hcache_delete(void *db, const char *filename, size_t (*keylen)(const 
char *fn));
 #endif /* USE_HCACHE */