summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-09 13:41:08 -0500
committerDan McGee <dan@archlinux.org>2011-06-09 14:16:55 -0500
commite826c143d3e9d21485f72c5490b2a907c936024e (patch)
treeca08e8327d7431d8ce97e6a3420def97a4f57620 /lib/libalpm
parent9d6568da0f55fb05ea5c28e06efb51046fd270bf (diff)
downloadpacman-e826c143d3e9d21485f72c5490b2a907c936024e.tar.xz
Kill all remaining 'PATH_MAX + 1' usages
The few remaining instances were utilized for buffers in calls to snprintf() and realpath(). Both of these functions will always ensure the returned value is padded with '\0', so there is no need for the extra byte. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c2
-rw-r--r--lib/libalpm/conflict.c6
-rw-r--r--lib/libalpm/handle.c2
-rw-r--r--lib/libalpm/remove.c4
4 files changed, 7 insertions, 7 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 59d539c6..0e216b6d 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -466,7 +466,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
size_t pkg_current, size_t pkg_count)
{
int i, ret = 0, errors = 0;
- char scriptlet[PATH_MAX+1];
+ char scriptlet[PATH_MAX];
int is_upgrade = 0;
pmpkg_t *oldpkg = NULL;
pmdb_t *db = handle->db_local;
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 89214707..dc067290 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -363,7 +363,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
for(current = 0, i = upgrade; i; i = i->next, current++) {
alpm_list_t *k, *tmpfiles = NULL;
pmpkg_t *p1, *p2, *dbpkg;
- char path[PATH_MAX+1];
+ char path[PATH_MAX];
p1 = i->data;
if(!p1) {
@@ -480,9 +480,9 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
}
if(!resolved_conflict && dbpkg) {
- char *rpath = calloc(PATH_MAX+1, sizeof(char));
+ char *rpath = calloc(PATH_MAX, sizeof(char));
if(!realpath(path, rpath)) {
- FREE(rpath);
+ free(rpath);
continue;
}
char *filestr = rpath + strlen(handle->root);
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 80ad5601..730372a7 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -328,7 +328,7 @@ enum _pmerrno_t _alpm_set_directory_option(const char *value,
if(stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
return PM_ERR_NOT_A_DIR;
}
- real = calloc(PATH_MAX + 1, sizeof(char));
+ real = calloc(PATH_MAX, sizeof(char));
if(!realpath(path, real)) {
free(real);
return PM_ERR_NOT_A_DIR;
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 27305ae3..a4b60cf4 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -186,7 +186,7 @@ int _alpm_remove_prepare(pmhandle_t *handle, alpm_list_t **data)
static int can_remove_file(pmhandle_t *handle, const char *path, alpm_list_t *skip)
{
- char file[PATH_MAX+1];
+ char file[PATH_MAX];
snprintf(file, PATH_MAX, "%s%s", handle->root, path);
@@ -215,7 +215,7 @@ static void unlink_file(pmhandle_t *handle, pmpkg_t *info, char *filename,
alpm_list_t *skip_remove, int nosave)
{
struct stat buf;
- char file[PATH_MAX+1];
+ char file[PATH_MAX];
snprintf(file, PATH_MAX, "%s%s", handle->root, filename);