1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-10 11:35:00 -05:00

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>
This commit is contained in:
Dan McGee 2011-06-09 13:41:08 -05:00
parent 9d6568da0f
commit e826c143d3
6 changed files with 9 additions and 9 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -512,7 +512,7 @@ static int _parseconfig(const char *file, int parse_options,
char **section, pmdb_t *db)
{
FILE *fp = NULL;
char line[PATH_MAX+1];
char line[PATH_MAX];
int linenum = 0;
char *ptr;
int ret = 0;

View File

@ -40,7 +40,7 @@ static char *resolve_path(const char *file)
{
char *str = NULL;
str = calloc(PATH_MAX + 1, sizeof(char));
str = calloc(PATH_MAX, sizeof(char));
if(!str) {
return NULL;
}