Add rpm_time_t type for time types (in headers), use where spotted
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 4 Feb 2008 09:50:39 +0000 (11:50 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 4 Feb 2008 09:50:39 +0000 (11:50 +0200)
- easy to spot, easy to change...
- time_t size can vary, header data needs fixed size

14 files changed:
build/files.c
build/names.c
build/parseChangelog.c
build/rpmbuild.h
lib/fsm.c
lib/psm.c
lib/query.c
lib/rpmds.c
lib/rpmfi.c
lib/rpmfi.h
lib/rpmfi_internal.h
lib/rpmtypes.h
rpmdb/header.c
tools/rpmcache.c

index c700a03..1c99c12 100644 (file)
@@ -233,7 +233,7 @@ static void timeCheck(int tc, Header h)
 {
     HGE_t hge = (HGE_t)headerGetEntryMinMemory;
     HFD_t hfd = headerFreeData;
-    int * mtime;
+    rpm_time_t * mtime;
     const char ** files;
     rpm_tagtype_t fnt;
     rpm_count_t count, x;
@@ -1137,8 +1137,8 @@ static void genCpioListAndHeader(FileList fl,
                               &(flp->uname), 1);
        (void) headerAddOrAppendEntry(h, RPMTAG_FILEGROUPNAME, RPM_STRING_ARRAY_TYPE,
                               &(flp->gname), 1);
-      if (sizeof(flp->fl_mtime) != sizeof(uint32_t)) {
-       uint32_t mtime = (uint32_t)flp->fl_mtime;
+      if (sizeof(flp->fl_mtime) != sizeof(rpm_time_t)) {
+       rpm_time_t mtime = (rpm_time_t)flp->fl_mtime;
        (void) headerAddOrAppendEntry(h, RPMTAG_FILEMTIMES, RPM_INT32_TYPE,
                               &(mtime), 1);
       } else {
index ccbeb29..0917a3c 100644 (file)
@@ -175,9 +175,9 @@ gid_t getGidS(const char *gname)
     return gids[gid_used++];
 }
 
-int32_t * getBuildTime(void)
+rpm_time_t * getBuildTime(void)
 {
-    static int32_t buildTime[1];
+    static rpm_time_t buildTime[1];
 
     if (buildTime[0] == 0)
        buildTime[0] = (int32_t) time(NULL);
index 15734b8..740ef22 100644 (file)
@@ -15,7 +15,7 @@
 
 void addChangelogEntry(Header h, time_t time, const char *name, const char *text)
 {
-    int32_t mytime = time;     /* XXX convert to header representation */
+    rpm_time_t mytime = time;  /* XXX convert to header representation */
     if (headerIsEntry(h, RPMTAG_CHANGELOGTIME)) {
        (void) headerAppendEntry(h, RPMTAG_CHANGELOGTIME, RPM_INT32_TYPE,
                          &mytime, 1);
index 3913f67..17e84d5 100644 (file)
@@ -143,7 +143,7 @@ extern const char * buildHost(void) ;
  * Return build time stamp.
  * @return             build time stamp
  */
-extern int32_t * getBuildTime(void)    ;
+extern rpm_time_t * getBuildTime(void) ;
 
 /** \ingroup rpmbuild
  * Read next line from spec file.
index bc11d04..4dce211 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -680,7 +680,7 @@ int fsmMapAttrs(FSM_t fsm)
        mode_t perms = (S_ISDIR(st->st_mode) ? fi->dperms : fi->fperms);
        mode_t finalMode = (fi->fmodes ? fi->fmodes[i] : perms);
        dev_t finalRdev = (fi->frdevs ? fi->frdevs[i] : 0);
-       int32_t finalMtime = (fi->fmtimes ? fi->fmtimes[i] : 0);
+       rpm_time_t finalMtime = (fi->fmtimes ? fi->fmtimes[i] : 0);
        uid_t uid = fi->uid;
        gid_t gid = fi->gid;
 
index 273e9e3..7c1b63c 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -1775,7 +1775,7 @@ assert(psm->mi == NULL);
        if (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)        break;
 
        if (psm->goal == PSM_PKGINSTALL) {
-           int32_t installTime = (int32_t) time(NULL);
+           rpm_time_t installTime = (rpm_time_t) time(NULL);
            rpm_count_t fc = rpmfiFC(fi);
 
            if (fi->h == NULL) break;   /* XXX can't happen */
index 75f5126..8e774fb 100644 (file)
@@ -183,7 +183,7 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h)
        rpmfileAttrs fflags;
        unsigned short fmode;
        unsigned short frdev;
-       unsigned int fmtime;
+       rpm_time_t fmtime;
        rpmfileState fstate;
        rpm_off_t fsize;
        const char * fn;
index 0d79e98..2f14d1f 100644 (file)
@@ -34,7 +34,7 @@ struct rpmds_s {
     rpmsenseFlags * Flags;     /*!< Bit(s) identifying context/comparison. */
     uint32_t * Color;          /*!< Bit(s) calculated from file color(s). */
     int32_t * Refs;            /*!< No. of file refs. */
-    int32_t BT;                        /*!< Package build time tie breaker. */
+    time_t BT;                 /*!< Package build time tie breaker. */
     rpm_tag_t tagN;            /*!< Header tag. */
     rpm_tagtype_t Nt, EVRt, Ft;        /*!< Tag data types. */
     int32_t Count;             /*!< No. of elements */
@@ -124,7 +124,7 @@ rpmds rpmdsNew(Header h, rpm_tag_t tagN, int flags)
        (scareMem ? (HGE_t) headerGetEntryMinMemory : (HGE_t) headerGetEntry);
     rpm_tag_t tagBT = RPMTAG_BUILDTIME;
     rpm_tagtype_t BTt;
-    int32_t * BTp;
+    rpm_time_t * BTp;
     rpm_tag_t tagEVR, tagF;
     rpmds ds = NULL;
     const char * Type;
index fe75c6b..155201d 100644 (file)
@@ -311,9 +311,9 @@ uint32_t rpmfiFNlink(rpmfi fi)
     return nlink;
 }
 
-uint32_t rpmfiFMtime(rpmfi fi)
+rpm_time_t rpmfiFMtime(rpmfi fi)
 {
-    uint32_t fmtime = 0;
+    rpm_time_t fmtime = 0;
 
     if (fi != NULL && fi->i >= 0 && fi->i < fi->fc) {
        if (fi->fmtimes != NULL)
index d2237d6..690b035 100644 (file)
@@ -288,7 +288,7 @@ uint32_t rpmfiFNlink(rpmfi fi);
  * @param fi           file info set
  * @return             current file modify time, 0 on invalid
  */
-uint32_t rpmfiFMtime(rpmfi fi);
+rpm_time_t rpmfiFMtime(rpmfi fi);
 
 /** \ingroup rpmfi
  * Return current file owner from file info set.
index ce3aab2..30124fd 100644 (file)
@@ -45,7 +45,7 @@ struct rpmfi_s {
 /*?null?*/
     const rpm_off_t * fsizes;  /*!< File size(s) (from header) */
 /*?null?*/
-    const uint32_t * fmtimes;  /*!< File modification time(s) (from header) */
+    const rpm_time_t * fmtimes;        /*!< File modification time(s) (from header) */
 /*?null?*/
           uint16_t * fmodes;   /*!< File mode(s) (from header) */
 /*?null?*/
index 3170b7b..a535b3b 100644 (file)
@@ -25,6 +25,7 @@ typedef void *                rpm_data_t;
 typedef const void *   rpm_constdata_t;
 
 typedef uint32_t       rpm_off_t;
+typedef uint32_t       rpm_time_t;
 
 typedef struct headerToken_s * Header;
 typedef struct headerIterator_s * HeaderIterator;
index 2f791a8..3b2a0de 100644 (file)
@@ -3178,8 +3178,8 @@ static char * realDateFormat(rpm_tagtype_t type, rpm_constdata_t data,
        val = xmalloc(50 + padding);
        strcat(formatPrefix, "s");
 
-       /* this is important if sizeof(int32_t) ! sizeof(time_t) */
-       {   time_t dateint = *((const int32_t *) data);
+       /* this is important if sizeof(rpm_time_t) ! sizeof(time_t) */
+       {   time_t dateint = *((const rpm_time_t *) data);
            tstruct = localtime(&dateint);
        }
        buf[0] = '\0';
index ccafe49..43bb2bf 100644 (file)
@@ -45,8 +45,8 @@ static int indent = 2;
 
 typedef struct Item_s {
     char * path;
-    int32_t size;
-    int32_t mtime;
+    rpm_off_t size;
+    rpm_time_t mtime;
     rpmds this;
     Header h;
 } * Item;