summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libalpm/be_files.c4
-rw-r--r--lib/libalpm/conflict.c6
-rw-r--r--lib/libalpm/db.c2
-rw-r--r--lib/libalpm/deps.c6
-rw-r--r--lib/libalpm/package.c32
-rw-r--r--lib/libalpm/server.c2
-rw-r--r--lib/libalpm/sync.c2
-rw-r--r--lib/libalpm/util.c2
-rw-r--r--lib/libalpm/util.h6
9 files changed, 29 insertions, 33 deletions
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 8c0b3d69..d720268f 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -141,7 +141,7 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, const char *target)
if(stat(path, &sbuf) || !S_ISDIR(sbuf.st_mode)) {
continue;
}
- STRNCPY(name, ent->d_name, PKG_FULLNAME_LEN);
+ strncpy(name, ent->d_name, PKG_FULLNAME_LEN);
/* truncate the string at the second-to-last hyphen, */
/* which will give us the package name */
if((ptr = rindex(name, '-'))) {
@@ -733,7 +733,7 @@ int _alpm_db_getlastupdate(pmdb_t *db, char *ts)
} else {
char line[256];
if(fgets(line, sizeof(line), fp)) {
- STRNCPY(ts, line, 15); /* YYYYMMDDHHMMSS */
+ strncpy(ts, line, 14); /* YYYYMMDDHHMMSS */
ts[14] = '\0';
} else {
fclose(fp);
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 472a4f69..3755fcd7 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -350,10 +350,10 @@ static alpm_list_t *add_fileconflict(alpm_list_t *conflicts,
return(conflicts);
}
conflict->type = type;
- STRNCPY(conflict->target, name1, PKG_NAME_LEN);
- STRNCPY(conflict->file, filestr, CONFLICT_FILE_LEN);
+ strncpy(conflict->target, name1, PKG_NAME_LEN);
+ strncpy(conflict->file, filestr, CONFLICT_FILE_LEN);
if(name2) {
- STRNCPY(conflict->ctarget, name2, PKG_NAME_LEN);
+ strncpy(conflict->ctarget, name2, PKG_NAME_LEN);
} else {
conflict->ctarget[0] = '\0';
}
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index eef27b7e..a1c1121d 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -74,7 +74,7 @@ pmdb_t *_alpm_db_new(const char *root, const char *dbpath, const char *treename)
}
sprintf(db->path, "%s%s%s/", root, dbpath, treename);
- STRNCPY(db->treename, treename, PATH_MAX);
+ strncpy(db->treename, treename, PATH_MAX);
return(db);
}
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 6f075bb8..51b3207f 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -60,12 +60,12 @@ pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
RET_ERR(PM_ERR_MEMORY, NULL);
}
- STRNCPY(miss->target, target, PKG_NAME_LEN);
+ strncpy(miss->target, target, PKG_NAME_LEN);
miss->type = type;
miss->depend.mod = depmod;
- STRNCPY(miss->depend.name, depname, PKG_NAME_LEN);
+ strncpy(miss->depend.name, depname, PKG_NAME_LEN);
if(depversion) {
- STRNCPY(miss->depend.version, depversion, PKG_VERSION_LEN);
+ strncpy(miss->depend.version, depversion, PKG_VERSION_LEN);
} else {
miss->depend.version[0] = 0;
}
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 246612c5..9a5ae8f4 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -58,12 +58,12 @@ pmpkg_t *_alpm_pkg_new(const char *name, const char *version)
}
if(name && name[0] != 0) {
- STRNCPY(pkg->name, name, PKG_NAME_LEN);
+ strncpy(pkg->name, name, PKG_NAME_LEN);
} else {
pkg->name[0] = '\0';
}
if(version && version[0] != 0) {
- STRNCPY(pkg->version, version, PKG_VERSION_LEN);
+ strncpy(pkg->version, version, PKG_VERSION_LEN);
} else {
pkg->version[0] = '\0';
}
@@ -219,9 +219,9 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
key = _alpm_strtoupper(key);
_alpm_strtrim(ptr);
if(!strcmp(key, "PKGNAME")) {
- STRNCPY(info->name, ptr, sizeof(info->name));
+ strncpy(info->name, ptr, sizeof(info->name));
} else if(!strcmp(key, "PKGVER")) {
- STRNCPY(info->version, ptr, sizeof(info->version));
+ strncpy(info->version, ptr, sizeof(info->version));
} else if(!strcmp(key, "PKGDESC")) {
/*
char *lang_tmp;
@@ -229,32 +229,32 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
- STRNCPY(lang_tmp, setlocale(LC_ALL, ""), strlen(setlocale(LC_ALL, "")));
+ strncpy(lang_tmp, setlocale(LC_ALL, ""), strlen(setlocale(LC_ALL, "")));
if(info->desc_localized && !info->desc_localized->next) {
*/
- STRNCPY(info->desc, ptr, sizeof(info->desc));
+ strncpy(info->desc, ptr, sizeof(info->desc));
/*
} else if (ptr && !strncmp(ptr, lang_tmp, strlen(lang_tmp))) {
- STRNCPY(info->desc, ptr+strlen(lang_tmp)+1, sizeof(info->desc));
+ strncpy(info->desc, ptr+strlen(lang_tmp)+1, sizeof(info->desc));
}
FREE(lang_tmp);
*/
} else if(!strcmp(key, "GROUP")) {
info->groups = alpm_list_add(info->groups, strdup(ptr));
} else if(!strcmp(key, "URL")) {
- STRNCPY(info->url, ptr, sizeof(info->url));
+ strncpy(info->url, ptr, sizeof(info->url));
} else if(!strcmp(key, "LICENSE")) {
info->licenses = alpm_list_add(info->licenses, strdup(ptr));
} else if(!strcmp(key, "BUILDDATE")) {
- STRNCPY(info->builddate, ptr, sizeof(info->builddate));
+ strncpy(info->builddate, ptr, sizeof(info->builddate));
} else if(!strcmp(key, "BUILDTYPE")) {
- STRNCPY(info->buildtype, ptr, sizeof(info->buildtype));
+ strncpy(info->buildtype, ptr, sizeof(info->buildtype));
} else if(!strcmp(key, "INSTALLDATE")) {
- STRNCPY(info->installdate, ptr, sizeof(info->installdate));
+ strncpy(info->installdate, ptr, sizeof(info->installdate));
} else if(!strcmp(key, "PACKAGER")) {
- STRNCPY(info->packager, ptr, sizeof(info->packager));
+ strncpy(info->packager, ptr, sizeof(info->packager));
} else if(!strcmp(key, "ARCH")) {
- STRNCPY(info->arch, ptr, sizeof(info->arch));
+ strncpy(info->arch, ptr, sizeof(info->arch));
} else if(!strcmp(key, "SIZE")) {
/* size in the raw package is uncompressed (installed) size */
info->isize = atol(ptr);
@@ -494,7 +494,7 @@ int _alpm_pkg_splitname(const char *target, char *name, char *version, int witha
} else {
t++;
}
- STRNCPY(tmp, t, PKG_FULLNAME_LEN+7);
+ strncpy(tmp, t, PKG_FULLNAME_LEN+7);
/* trim file extension (if any) */
if((p = strstr(tmp, PM_EXT_PKG))) {
*p = '\0';
@@ -518,12 +518,12 @@ int _alpm_pkg_splitname(const char *target, char *name, char *version, int witha
return(-1);
}
if(version) {
- STRNCPY(version, p+1, PKG_VERSION_LEN);
+ strncpy(version, p+1, PKG_VERSION_LEN);
}
*p = '\0';
if(name) {
- STRNCPY(name, tmp, PKG_NAME_LEN);
+ strncpy(name, tmp, PKG_NAME_LEN);
}
return(0);
diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c
index 1b629a81..c34c9215 100644
--- a/lib/libalpm/server.c
+++ b/lib/libalpm/server.c
@@ -197,7 +197,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
}
if(!strlen(pkgname)) {
/* just use the raw filename if we can't find crap */
- STRNCPY(pkgname, fn, PKG_NAME_LEN+1);
+ strncpy(pkgname, fn, PKG_NAME_LEN);
}
_alpm_log(PM_LOG_DEBUG, _("using '%s' for download progress"), pkgname);
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 603504e8..9af25c13 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -266,7 +266,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- STRNCPY(targline, name, PKG_FULLNAME_LEN);
+ strncpy(targline, name, PKG_FULLNAME_LEN);
targ = strchr(targline, '/');
if(targ) {
*targ = '\0';
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 715de218..1f7b7190 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -449,7 +449,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
/* chop off the root so we can find the tmpdir in the chroot */
scriptpath = scriptfn + strlen(root) - 1;
} else {
- STRNCPY(scriptfn, installfn, PATH_MAX);
+ strncpy(scriptfn, installfn, PATH_MAX);
/* chop off the root so we can find the tmpdir in the chroot */
scriptpath = scriptfn + strlen(root) - 1;
}
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index c4131795..0584b73b 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -34,11 +34,6 @@
#define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0)
-#define STRNCPY(s1, s2, len) do { \
- strncpy(s1, s2, (len)-1); \
- s1[(len)-1] = 0; \
-} while(0)
-
#define ARCHIVE_EXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME
/* define _() as shortcut for gettext() */
@@ -62,6 +57,7 @@ int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
int _alpm_rmrf(const char *path);
int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
int _alpm_ldconfig(const char *root);
+/* TODO wtf? this can't be right */
#ifdef _ALPM_TRANS_H
int _alpm_runscriptlet(const char *root, const char *installfn,
const char *script, const char *ver,