Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=b7a2735f88304947b0324f622e250ff29bf665f6

commit b7a2735f88304947b0324f622e250ff29bf665f6
Author: Michel Hermier <herm...@frugalware.org>
Date:   Thu Nov 14 08:31:03 2013 +0100

libpacman: Define PM_TIME_INVALID so we have the same symbol everywhere.

diff --git a/lib/libpacman/db/syncdb.c b/lib/libpacman/db/syncdb.c
index 2e7d73e..0830a97 100644
--- a/lib/libpacman/db/syncdb.c
+++ b/lib/libpacman/db/syncdb.c
@@ -46,6 +46,7 @@
#include "io/archive.h"
#include "util/log.h"
#include "util/stringlist.h"
+#include "util/time.h"
#include "util.h"
#include "cache.h"
#include "db.h"
@@ -94,14 +95,14 @@ int _pacman_syncdb_update(pmdb_t *db, int force)
{
char path[PATH_MAX], dirpath[PATH_MAX];
pmlist_t *files = NULL;
-       time_t newmtime = ((time_t) -1);
-       time_t timestamp = ((time_t) -1);
+       time_t newmtime = PM_TIME_INVALID;
+       time_t timestamp = PM_TIME_INVALID;
int ret, updated=0;

if(!force) {
/* get the lastupdate time */
_pacman_db_gettimestamp(db, &timestamp);
-               if(timestamp == ((time_t) -1)) {
+               if(timestamp == PM_TIME_INVALID) {
_pacman_log(PM_LOG_DEBUG, _("failed to get lastupdate time for %s (no big 
deal)\n"), db->treename);
}
}
@@ -121,7 +122,7 @@ int _pacman_syncdb_update(pmdb_t *db, int force)
}
return 1; /* Means up2date */
} else {
-               if(newmtime != ((time_t) -1)) {
+               if(newmtime != PM_TIME_INVALID) {
_pacman_log(PM_LOG_DEBUG, _("sync: new mtime for %s: %s\n"), db->treename, 
newmtime);
updated = 1;
}
diff --git a/lib/libpacman/io/archive.h b/lib/libpacman/io/archive.h
index 6f7a1ea..e296b89 100644
--- a/lib/libpacman/io/archive.h
+++ b/lib/libpacman/io/archive.h
@@ -26,6 +26,6 @@
struct archive *_pacman_archive_read_open_all_file(const char *file);
FILE *_pacman_archive_read_fropen(struct archive *a);

-#endif /* _PACMAN_UTIL_H */
+#endif /* _PACMAN_ARCHIVE_FILE_H */

/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libpacman/io/ftp.c b/lib/libpacman/io/ftp.c
index 373084f..a4e8333 100644
--- a/lib/libpacman/io/ftp.c
+++ b/lib/libpacman/io/ftp.c
@@ -45,7 +45,7 @@ char *_pacman_ftp_strpmdtm(const char *s, time_t *time)
if((ret = strptime(s, PM_FTP_MDTM_FORMAT, &ptimestamp)) != NULL) {
time_t tmp;

-               if((tmp = mktime(&ptimestamp)) != ((time_t) -1)) {
+               if((tmp = mktime(&ptimestamp)) != PM_TIME_INVALID) {
*time = tmp;
} else {
ret = NULL;
diff --git a/lib/libpacman/server.c b/lib/libpacman/server.c
index 52d1f03..c4aed22 100644
--- a/lib/libpacman/server.c
+++ b/lib/libpacman/server.c
@@ -39,6 +39,7 @@
#include "util/list.h"
#include "util/log.h"
#include "util/stringlist.h"
+#include "util/time.h"
#include "error.h"
#include "pacman.h"
#include "util.h"
@@ -484,7 +485,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const 
char *localpath,
} else {
snprintf(src, PATH_MAX, "%s://%s%s%s", server->protocol, server->server, 
server->path, fn);
}
-                                       if(mtime1 && *mtime1 != ((time_t) -1)) {
+                                       if(mtime1 && *mtime1 != 
PM_TIME_INVALID) {
fmtime1 = *gmtime(mtime1);
}
if(!HttpGet(server->server, output, src, &fsz, control, (pm_dloffset ? 
*pm_dloffset:0),
@@ -505,7 +506,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const 
char *localpath,
}
} else {
if(mtime2) {
-                                                       if((*mtime2 = 
mktime(&fmtime2)) == ((time_t) -1)) {
+                                                       if((*mtime2 = 
mktime(&fmtime2)) == PM_TIME_INVALID) {
_pacman_log(PM_LOG_WARNING, _("failed to get mtime for %s\n"), fn);
}
}
diff --git a/lib/libpacman/util/time.c b/lib/libpacman/util/time.c
index 17d16b3..bd51514 100644
--- a/lib/libpacman/util/time.c
+++ b/lib/libpacman/util/time.c
@@ -51,7 +51,7 @@ struct tm *_pacman_localtime(const time_t *timep)
time_t now;

if(timep == NULL &&
-               (now = time(NULL)) != ((time_t) -1)) {
+               (now = time(NULL)) != PM_TIME_INVALID) {
timep = &now;
}
return localtime(timep);
diff --git a/lib/libpacman/util/time.h b/lib/libpacman/util/time.h
index a482976..51c0b55 100644
--- a/lib/libpacman/util/time.h
+++ b/lib/libpacman/util/time.h
@@ -23,6 +23,8 @@

#include <time.h>

+#define PM_TIME_INVALID ((time_t) -1)
+
/* Return the localtime for timep. If timep is NULL, return the conversion for 
time(NULL) (libc returns NULL instead).
*/
struct tm *_pacman_localtime(const time_t *timep);
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to