diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 09034067..59ea151c 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -155,7 +155,7 @@ enum { }; /* reasons -- ie, why the package was installed */ -#define PM_PKG_REASON_EXPLICIT 0 /* explicitly requested by the user */ +#define PM_PKG_REASON_EXPLICIT 0 /* explicitly requested by the user */ #define PM_PKG_REASON_DEPEND 1 /* installed as a dependency for another package */ void *alpm_pkg_getinfo(PM_PKG *pkg, unsigned char parm); @@ -367,7 +367,7 @@ extern enum __pmerrno_t { char *alpm_strerror(int err); -#ifdef __cplusplus +#ifdef __cplusplus } #endif diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 63e7bc48..00e3d5a8 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -514,25 +514,25 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList ** /* abort */ _alpm_log(PM_LOG_ERROR, "package conflicts detected"); errorout = 1; - if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - FREELIST(*data); - pm_errno = PM_ERR_MEMORY; - goto error; - } - *miss = *(pmdepmissing_t *)i->data; - *data = pm_list_add(*data, miss); + if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { + FREELIST(*data); + pm_errno = PM_ERR_MEMORY; + goto error; + } + *miss = *(pmdepmissing_t *)i->data; + *data = pm_list_add(*data, miss); } } } else { _alpm_log(PM_LOG_ERROR, "%s conflicts with %s", miss->target, miss->depend.name); errorout = 1; - if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - FREELIST(*data); - pm_errno = PM_ERR_MEMORY; - goto error; - } - *miss = *(pmdepmissing_t *)i->data; - *data = pm_list_add(*data, miss); + if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { + FREELIST(*data); + pm_errno = PM_ERR_MEMORY; + goto error; + } + *miss = *(pmdepmissing_t *)i->data; + *data = pm_list_add(*data, miss); } } } diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 8c0b38a7..79287d34 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -328,8 +328,10 @@ int _alpm_log_action(unsigned char usesyslog, FILE *f, char *fmt, ...) t = time(NULL); tm = localtime(&t); - fprintf(f, "[%02d/%02d/%02d %02d:%02d] %s\n", tm->tm_mon+1, tm->tm_mday, - tm->tm_year-100, tm->tm_hour, tm->tm_min, msg); + fprintf(f, "[%02d/%02d/%02d %02d:%02d] %s\n", + tm->tm_mon+1, tm->tm_mday, tm->tm_year-100, + tm->tm_hour, tm->tm_min, + msg); } return(0); diff --git a/lib/libftp/ftplib.c b/lib/libftp/ftplib.c index 8be3cac1..262cac0b 100644 --- a/lib/libftp/ftplib.c +++ b/lib/libftp/ftplib.c @@ -1513,8 +1513,8 @@ static int HttpXfer(const char *localfile, const char *path, int *size, * return 1 if successful, 0 otherwise */ GLOBALREF int HttpGet(const char *host, const char *outputfile, const char *path, - int *size, netbuf *nControl, unsigned int offset, - const struct tm *mtime1, struct tm *mtime2) + int *size, netbuf *nControl, unsigned int offset, + const struct tm *mtime1, struct tm *mtime2) { char buf[512]; diff --git a/src/pacman/download.c b/src/pacman/download.c index 3e44b921..42d0bc8d 100644 --- a/src/pacman/download.c +++ b/src/pacman/download.c @@ -467,7 +467,7 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, } } else { if(mtime2) { - if(fmtime2.tm_year) { + if(fmtime2.tm_year) { /* date conversion from "rfc1123-date" to YYYYMMDDHHMMSS */ sprintf(mtime2, "%4d%02d%02d%02d%02d%02d", fmtime2.tm_year+1900, fmtime2.tm_mon+1, fmtime2.tm_mday, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 0a685907..5ad000aa 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -168,7 +168,7 @@ int main(int argc, char *argv[]) cleanup(1); } - for(lp = config->op_s_ignore; lp; lp = lp->next) { + for(lp = config->op_s_ignore; lp; lp = lp->next) { if(alpm_set_option(PM_OPT_IGNOREPKG, (long)lp->data) == -1) { ERR(NL, "failed to set option IGNOREPKG (%s)\n", alpm_strerror(pm_errno)); cleanup(1); diff --git a/src/pacman/trans.c b/src/pacman/trans.c index e960472c..f97c91fa 100644 --- a/src/pacman/trans.c +++ b/src/pacman/trans.c @@ -66,8 +66,8 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2) case PM_TRANS_EVT_ADD_DONE: MSG(CL, "done.\n"); snprintf(str, LOG_STR_LEN, "installed %s (%s)", - (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), - (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); + (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), + (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); alpm_logaction(str); break; case PM_TRANS_EVT_REMOVE_START: @@ -86,9 +86,9 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2) case PM_TRANS_EVT_UPGRADE_DONE: MSG(CL, "done.\n"); snprintf(str, LOG_STR_LEN, "upgraded %s (%s -> %s)", - (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), - (char *)alpm_pkg_getinfo(data2, PM_PKG_VERSION), - (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); + (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), + (char *)alpm_pkg_getinfo(data2, PM_PKG_VERSION), + (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); alpm_logaction(str); break; } @@ -101,34 +101,34 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i switch(event) { case PM_TRANS_CONV_INSTALL_IGNOREPKG: snprintf(str, LOG_STR_LEN, ":: %s requires %s, but it is in IgnorePkg. Install anyway? [Y/n] ", - (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), - (char *)alpm_pkg_getinfo(data2, PM_PKG_NAME)); + (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), + (char *)alpm_pkg_getinfo(data2, PM_PKG_NAME)); *response = yesno(str); break; case PM_TRANS_CONV_REPLACE_PKG: snprintf(str, LOG_STR_LEN, ":: Replace %s with %s/%s? [Y/n] ", - (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), - (char *)data3, - (char *)alpm_pkg_getinfo(data2, PM_PKG_NAME)); + (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), + (char *)data3, + (char *)alpm_pkg_getinfo(data2, PM_PKG_NAME)); *response = yesno(str); break; case PM_TRANS_CONV_CONFLICT_PKG: snprintf(str, LOG_STR_LEN, "\n:: %s conflicts with %s. Remove %s? [Y/n] ", - (char *)data1, - (char *)data2, - (char *)data2); + (char *)data1, + (char *)data2, + (char *)data2); *response = yesno(str); break; case PM_TRANS_CONV_LOCAL_NEWER: snprintf(str, LOG_STR_LEN, ":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ", - (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), - (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); + (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), + (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); *response = yesno(str); break; case PM_TRANS_CONV_LOCAL_UPTODATE: snprintf(str, LOG_STR_LEN, ":: %s-%s: local version is up to date. Upgrade anyway? [Y/n] ", - (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), - (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); + (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), + (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION)); *response = yesno(str); break; } diff --git a/src/pacman/util.c b/src/pacman/util.c index dd8dddab..a279e004 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -79,7 +79,6 @@ int rmrf(char *path) int errflag = 0; struct dirent *dp; DIR *dirp; - char name[PATH_MAX]; if(!unlink(path)) { return(0); @@ -102,6 +101,7 @@ int rmrf(char *path) } for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { if(dp->d_ino) { + char name[PATH_MAX]; sprintf(name, "%s/%s", path, dp->d_name); if(strcmp(dp->d_name, "..") && strcmp(dp->d_name, ".")) { errflag += rmrf(name); diff --git a/src/pacman/util.h b/src/pacman/util.h index b4a9d130..f9d8d847 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -21,10 +21,17 @@ #ifndef _PM_UTIL_H #define _PM_UTIL_H -#define MALLOC(p, b) do { if((b) > 0) { \ - p = malloc(b); if (!(p)) { \ - fprintf(stderr, "malloc failure: could not allocate %d bytes\n", b); \ - exit(1); }} else p = NULL; } while(0) +#define MALLOC(p, b) do { \ + if((b) > 0) { \ + p = malloc(b); \ + if (!(p)) { \ + fprintf(stderr, "malloc failure: could not allocate %d bytes\n", b); \ + exit(1); \ + } \ + } else { \ + p = NULL; \ + } \ +} while(0) #define FREE(p) do { if (p) { free(p); (p) = NULL; }} while(0) diff --git a/src/util/convertdb.c b/src/util/convertdb.c index 8738364c..227df0e8 100644 --- a/src/util/convertdb.c +++ b/src/util/convertdb.c @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) mode_t oldumask; struct stat buf; char dbdir[PATH_MAX]; - + sprintf(dbdir, "/%s", PM_DBPATH); if(argc < 2) {