diff options
Diffstat (limited to 'src/pacman')
| -rw-r--r-- | src/pacman/callback.c | 2 | ||||
| -rw-r--r-- | src/pacman/conf.c | 8 | ||||
| -rw-r--r-- | src/pacman/database.c | 10 | ||||
| -rw-r--r-- | src/pacman/deptest.c | 4 | ||||
| -rw-r--r-- | src/pacman/package.c | 4 | ||||
| -rw-r--r-- | src/pacman/pacman.c | 100 | ||||
| -rw-r--r-- | src/pacman/query.c | 60 | ||||
| -rw-r--r-- | src/pacman/remove.c | 16 | ||||
| -rw-r--r-- | src/pacman/sync.c | 86 | ||||
| -rw-r--r-- | src/pacman/upgrade.c | 22 | ||||
| -rw-r--r-- | src/pacman/util.c | 122 | 
11 files changed, 217 insertions, 217 deletions
| diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 5edcc966..08c1cf3f 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -81,7 +81,7 @@ static double get_update_timediff(int first_call)  		}  	} -	return(retval); +	return retval;  }  /* refactored from cb_trans_progress */ diff --git a/src/pacman/conf.c b/src/pacman/conf.c index e2a168ee..69110ab9 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -38,7 +38,7 @@ config_t *config_new(void)  			pm_fprintf(stderr, PM_LOG_ERROR,  					_("malloc failure: could not allocate %zd bytes\n"),  					sizeof(config_t)); -			return(NULL); +			return NULL;  	}  	/* defaults which may get overridden later */  	newconfig->op = PM_OP_MAIN; @@ -46,13 +46,13 @@ config_t *config_new(void)  	/* CONFFILE is defined at compile-time */  	newconfig->configfile = strdup(CONFFILE); -	return(newconfig); +	return newconfig;  }  int config_free(config_t *oldconfig)  {  	if(oldconfig == NULL) { -		return(-1); +		return -1;  	}  	FREELIST(oldconfig->holdpkg); @@ -66,7 +66,7 @@ int config_free(config_t *oldconfig)  	free(oldconfig);  	oldconfig = NULL; -	return(0); +	return 0;  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/database.c b/src/pacman/database.c index 36433f33..9d6edab5 100644 --- a/src/pacman/database.c +++ b/src/pacman/database.c @@ -47,7 +47,7 @@ int pacman_database(alpm_list_t *targets)  	if(targets == NULL) {  		pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); -		return(1); +		return 1;  	}  	if(config->flags & PM_TRANS_FLAG_ALLDEPS) { /* --asdeps */ @@ -56,12 +56,12 @@ int pacman_database(alpm_list_t *targets)  		reason = PM_PKG_REASON_EXPLICIT;  	} else {  		pm_printf(PM_LOG_ERROR, _("no install reason specified (use -h for help)\n")); -		return(1); +		return 1;  	}  	/* Lock database */  	if(trans_init(0) == -1) { -		return(1); +		return 1;  	}  	db_local = alpm_option_get_localdb(); @@ -82,9 +82,9 @@ int pacman_database(alpm_list_t *targets)  	/* Unlock database */  	if(trans_release() == -1) { -		return(1); +		return 1;  	} -	return(retval); +	return retval;  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c index 8895b487..cc1e565b 100644 --- a/src/pacman/deptest.c +++ b/src/pacman/deptest.c @@ -47,7 +47,7 @@ int pacman_deptest(alpm_list_t *targets)  	}  	if(deps == NULL) { -		return(0); +		return 0;  	}  	for(i = deps; i; i = alpm_list_next(i)) { @@ -56,7 +56,7 @@ int pacman_deptest(alpm_list_t *targets)  		printf("%s\n", dep);  	}  	alpm_list_free(deps); -	return(127); +	return 127;  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/package.c b/src/pacman/package.c index 77a5ee72..d8dde695 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -173,7 +173,7 @@ static const char *get_backup_file_status(const char *root,  		if(md5sum == NULL) {  			pm_fprintf(stderr, PM_LOG_ERROR,  					_("could not calculate checksums for %s\n"), path); -			return(NULL); +			return NULL;  		}  		/* if checksums don't match, file has been modified */ @@ -195,7 +195,7 @@ static const char *get_backup_file_status(const char *root,  				ret = "UNKNOWN";  		}  	} -	return(ret); +	return ret;  }  /* Display list of backup files and their modification states diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index fc34f0e9..e4555c03 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -66,9 +66,9 @@ static int options_cmp(const void *p1, const void *p2)  	const char *s1 = p1;  	const char *s2 = p2; -	if(s1 == s2) return(0); -	if(!s1) return(-1); -	if(!s2) return(1); +	if(s1 == s2) return 0; +	if(!s1) return -1; +	if(!s2) return 1;  	/* First skip all spaces in both strings */  	while(isspace((unsigned char)*s1)) {  		s1++; @@ -87,15 +87,15 @@ static int options_cmp(const void *p1, const void *p2)  			s2++;  		} else if(*s2 == '-') {  			/* s1 short, s2 long */ -			return(-1); +			return -1;  		} else if(*s1 == '-') {  			/* s1 long, s2 short */ -			return(1); +			return 1;  		}  		/* two short -> strcmp */  	} -	return(strcmp(s1, s2)); +	return strcmp(s1, s2);  }  /** Display usage/syntax for the specified operation. @@ -297,7 +297,7 @@ static ssize_t xwrite(int fd, const void *buf, size_t count)  	do {  		ret = write(fd, buf, count);  	} while(ret == -1 && errno == EINTR); -	return(ret); +	return ret;  }  /** Catches thrown signals. Performs necessary cleanup to ensure database is @@ -393,7 +393,7 @@ static void setlibpaths(void)  	}  } -#define check_optarg() if(!optarg) { return(1); } +#define check_optarg() if(!optarg) { return 1; }  typedef void (*fn_add) (const char *s); @@ -407,7 +407,7 @@ static int parsearg_util_addlist(fn_add fn)  		fn((char *)alpm_list_getdata(item));  	}  	FREELIST(list); -	return(0); +	return 0;  }  /** Helper function for parsing operation from command-line arguments. @@ -444,9 +444,9 @@ static int parsearg_op(int opt, int dryrun)  			if(dryrun) break;  			config->help = 1; break;  		default: -			return(1); +			return 1;  	} -	return(0); +	return 0;  }  /** Helper functions for parsing command-line arguments. @@ -467,7 +467,7 @@ static int parsearg_global(int opt)  			if(alpm_option_add_cachedir(optarg) != 0) {  				pm_printf(PM_LOG_ERROR, _("problem adding cachedir '%s' (%s)\n"),  						optarg, alpm_strerrorlast()); -				return(1); +				return 1;  			}  			break;  		case OP_CONFIG: @@ -492,7 +492,7 @@ static int parsearg_global(int opt)  					default:  						pm_printf(PM_LOG_ERROR, _("'%s' is not a valid debug level\n"),  								optarg); -						return(1); +						return 1;  				}  			} else {  				config->logmask |= PM_LOG_DEBUG; @@ -511,9 +511,9 @@ static int parsearg_global(int opt)  			break;  		case 'r': check_optarg(); config->rootdir = strdup(optarg); break;  		case 'v': (config->verbose)++; break; -		default: return(1); +		default: return 1;  	} -	return(0); +	return 0;  }  static int parsearg_database(int opt) @@ -521,9 +521,9 @@ static int parsearg_database(int opt)  	switch(opt) {  		case OP_ASDEPS: config->flags |= PM_TRANS_FLAG_ALLDEPS; break;  		case OP_ASEXPLICIT: config->flags |= PM_TRANS_FLAG_ALLEXPLICIT; break; -		default: return(1); +		default: return 1;  	} -	return(0); +	return 0;  }  static int parsearg_query(int opt) @@ -543,9 +543,9 @@ static int parsearg_query(int opt)  		case 's': config->op_q_search = 1; break;  		case 't': config->op_q_unrequired = 1; break;  		case 'u': config->op_q_upgrade = 1; break; -		default: return(1); +		default: return 1;  	} -	return(0); +	return 0;  }  /* options common to -S -R -U */ @@ -567,15 +567,15 @@ static int parsearg_trans(int opt)  			check_optarg();  			config->print_format = strdup(optarg);  			break; -		default: return(1); +		default: return 1;  	} -	return(0); +	return 0;  }  static int parsearg_remove(int opt)  {  	if (parsearg_trans(opt) == 0) -		return(0); +		return 0;  	switch(opt) {  		case 'c': config->flags |= PM_TRANS_FLAG_CASCADE; break;  		case 'n': config->flags |= PM_TRANS_FLAG_NOSAVE; break; @@ -587,16 +587,16 @@ static int parsearg_remove(int opt)  			}  			break;  		case 'u': config->flags |= PM_TRANS_FLAG_UNNEEDED; break; -		default: return(1); +		default: return 1;  	} -	return(0); +	return 0;  }  /* options common to -S -U */  static int parsearg_upgrade(int opt)  {  	if (parsearg_trans(opt) == 0) -		return(0); +		return 0;  	switch(opt) {  		case 'f': config->flags |= PM_TRANS_FLAG_FORCE; break;  		case OP_ASDEPS: config->flags |= PM_TRANS_FLAG_ALLDEPS; break; @@ -607,15 +607,15 @@ static int parsearg_upgrade(int opt)  		case OP_IGNOREGROUP:  			parsearg_util_addlist(alpm_option_add_ignoregrp);  			break; -		default: return(1); +		default: return 1;  	} -	return(0); +	return 0;  }  static int parsearg_sync(int opt)  {  	if (parsearg_upgrade(opt) == 0) -		return(0); +		return 0;  	switch(opt) {  		case OP_NEEDED: config->flags |= PM_TRANS_FLAG_NEEDED; break;  		case 'c': (config->op_s_clean)++; break; @@ -631,9 +631,9 @@ static int parsearg_sync(int opt)  			config->flags |= PM_TRANS_FLAG_NOCONFLICTS;  			break;  		case 'y': (config->op_s_sync)++; break; -		default: return(1); +		default: return 1;  	} -	return(0); +	return 0;  }  /** Parse command-line arguments for each operation. @@ -712,22 +712,22 @@ static int parseargs(int argc, char *argv[])  			continue;  		} else if(opt == '?') {  			/* unknown option, getopt printed an error */ -			return(1); +			return 1;  		}  		parsearg_op(opt, 0);  	}  	if(config->op == 0) {  		pm_printf(PM_LOG_ERROR, _("only one operation may be used at a time\n")); -		return(1); +		return 1;  	}  	if(config->help) {  		usage(config->op, mbasename(argv[0])); -		return(2); +		return 2;  	}  	if(config->version) {  		version(); -		return(2); +		return 2;  	}  	/* parse all other options */ @@ -739,7 +739,7 @@ static int parseargs(int argc, char *argv[])  			continue;  		} else if(opt == '?') {  			/* this should have failed during first pass already */ -			return(1); +			return 1;  		} else if(parsearg_op(opt, 1) == 0) {  			/* opt is an operation */  			continue; @@ -775,7 +775,7 @@ static int parseargs(int argc, char *argv[])  		if(result != 0) {  			/* global option parsing failed, abort */  			pm_printf(PM_LOG_ERROR, _("invalid option\n")); -			return(result); +			return result;  		}  	} @@ -785,7 +785,7 @@ static int parseargs(int argc, char *argv[])  		optind++;  	} -	return(0); +	return 0;  }  /* helper for being used with setrepeatingoption */ @@ -838,7 +838,7 @@ static char *get_filename(const char *url) {  	if(filename != NULL) {  		filename++;  	} -	return(filename); +	return filename;  }  static char *get_destfile(const char *path, const char *filename) { @@ -848,7 +848,7 @@ static char *get_destfile(const char *path, const char *filename) {  	destfile = calloc(len, sizeof(char));  	snprintf(destfile, len, "%s%s", path, filename); -	return(destfile); +	return destfile;  }  static char *get_tempfile(const char *path, const char *filename) { @@ -858,7 +858,7 @@ static char *get_tempfile(const char *path, const char *filename) {  	tempfile = calloc(len, sizeof(char));  	snprintf(tempfile, len, "%s%s.part", path, filename); -	return(tempfile); +	return tempfile;  }  /** External fetch callback */ @@ -950,7 +950,7 @@ cleanup:  	free(tempfile);  	free(parsedcmd); -	return(ret); +	return ret;  }  static int _parse_options(const char *key, char *value, @@ -1008,7 +1008,7 @@ static int _parse_options(const char *key, char *value,  			if(alpm_option_add_cachedir(value) != 0) {  				pm_printf(PM_LOG_ERROR, _("problem adding cachedir '%s' (%s)\n"),  						value, alpm_strerrorlast()); -				return(1); +				return 1;  			}  			pm_printf(PM_LOG_DEBUG, "config: cachedir: %s\n", value);  		} else if(strcmp(key, "RootDir") == 0) { @@ -1036,7 +1036,7 @@ static int _parse_options(const char *key, char *value,  		}  	} -	return(0); +	return 0;  }  static int _add_mirror(pmdb_t *db, char *value) @@ -1055,7 +1055,7 @@ static int _add_mirror(pmdb_t *db, char *value)  			free(temp);  			pm_printf(PM_LOG_ERROR, _("The mirror '%s' contains the $arch"  						" variable, but no Architecture is defined.\n"), value); -			return(1); +			return 1;  		}  		server = temp;  	} @@ -1065,11 +1065,11 @@ static int _add_mirror(pmdb_t *db, char *value)  		pm_printf(PM_LOG_ERROR, _("could not add server URL to database '%s': %s (%s)\n"),  				dbname, server, alpm_strerrorlast());  		free(server); -		return(1); +		return 1;  	}  	free(server); -	return(0); +	return 0;  }  /* The real parseconfig. Called with a null section argument by the publicly @@ -1088,7 +1088,7 @@ static int _parseconfig(const char *file, const char *givensection,  	fp = fopen(file, "r");  	if(fp == NULL) {  		pm_printf(PM_LOG_ERROR, _("config file %s could not be read.\n"), file); -		return(1); +		return 1;  	}  	/* if we are passed a section, use it as our starting point */ @@ -1237,7 +1237,7 @@ cleanup:  	/* call setlibpaths here to ensure we have called it at least once */  	setlibpaths();  	pm_printf(PM_LOG_DEBUG, "config: finished parsing %s\n", file); -	return(ret); +	return ret;  }  /** Parse a configuration file. @@ -1247,7 +1247,7 @@ cleanup:  static int parseconfig(const char *file)  {  	/* call the real parseconfig function with a null section & db argument */ -	return(_parseconfig(file, NULL, NULL)); +	return _parseconfig(file, NULL, NULL);  }  /** print commandline to logfile @@ -1474,7 +1474,7 @@ int main(int argc, char *argv[])  	cleanup(ret);  	/* not reached */ -	return(EXIT_SUCCESS); +	return EXIT_SUCCESS;  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/query.c b/src/pacman/query.c index bd23d466..d2bfe690 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -43,15 +43,15 @@ static char *resolve_path(const char *file)  	str = calloc(PATH_MAX + 1, sizeof(char));  	if(!str) { -		return(NULL); +		return NULL;  	}  	if(!realpath(file, str)) {  		free(str); -		return(NULL); +		return NULL;  	} -	return(str); +	return str;  }  /* check if filename exists in PATH */ @@ -61,10 +61,10 @@ static int search_path(char **filename, struct stat *bufptr)  	size_t flen;  	if ((envpath = getenv("PATH")) == NULL) { -		return(-1); +		return -1;  	}  	if ((envpath = envpathsplit = strdup(envpath)) == NULL) { -		return(-1); +		return -1;  	}  	flen = strlen(*filename); @@ -84,12 +84,12 @@ static int search_path(char **filename, struct stat *bufptr)  			free(*filename);  			*filename = fullname;  			free(envpath); -			return(0); +			return 0;  		}  		free(fullname);  	}  	free(envpath); -	return(-1); +	return -1;  }  static int query_fileowner(alpm_list_t *targets) @@ -105,7 +105,7 @@ static int query_fileowner(alpm_list_t *targets)  	/* This code is here for safety only */  	if(targets == NULL) {  		pm_fprintf(stderr, PM_LOG_ERROR, _("no file was specified for --owns\n")); -		return(1); +		return 1;  	}  	/* Set up our root path buffer. We only need to copy the location of root in @@ -232,7 +232,7 @@ static int query_search(alpm_list_t *targets)  		freelist = 0;  	}  	if(searchlist == NULL) { -		return(1); +		return 1;  	}  	for(i = searchlist; i; i = alpm_list_next(i)) { @@ -280,7 +280,7 @@ static int query_search(alpm_list_t *targets)  	if(freelist) {  		alpm_list_free(searchlist);  	} -	return(0); +	return 0;  }  static int query_group(alpm_list_t *targets) @@ -343,19 +343,19 @@ static int is_foreign(pmpkg_t *pkg)  		}  	}  	if(match == 0) { -		return(1); +		return 1;  	} -	return(0); +	return 0;  }  static int is_unrequired(pmpkg_t *pkg)  {  	alpm_list_t *requiredby = alpm_pkg_compute_requiredby(pkg);  	if(requiredby == NULL) { -		return(1); +		return 1;  	}  	FREELIST(requiredby); -	return(0); +	return 0;  }  static int filter(pmpkg_t *pkg) @@ -363,26 +363,26 @@ static int filter(pmpkg_t *pkg)  	/* check if this package was explicitly installed */  	if(config->op_q_explicit &&  			alpm_pkg_get_reason(pkg) != PM_PKG_REASON_EXPLICIT) { -		return(0); +		return 0;  	}  	/* check if this package was installed as a dependency */  	if(config->op_q_deps &&  			alpm_pkg_get_reason(pkg) != PM_PKG_REASON_DEPEND) { -		return(0); +		return 0;  	}  	/* check if this pkg isn't in a sync DB */  	if(config->op_q_foreign && !is_foreign(pkg)) { -		return(0); +		return 0;  	}  	/* check if this pkg is unrequired */  	if(config->op_q_unrequired && !is_unrequired(pkg)) { -		return(0); +		return 0;  	}  	/* check if this pkg is outdated */  	if(config->op_q_upgrade && (alpm_sync_newversion(pkg, alpm_option_get_syncdbs()) == NULL)) { -		return(0); +		return 0;  	} -	return(1); +	return 1;  }  /* Loop through the packages. For each package, @@ -400,7 +400,7 @@ static int check(pmpkg_t *pkg)  	if(rootlen + 1 > PATH_MAX) {  		/* we are in trouble here */  		pm_fprintf(stderr, PM_LOG_ERROR, _("path too long: %s%s\n"), root, ""); -		return(1); +		return 1;  	}  	strcpy(f, root); @@ -434,7 +434,7 @@ static int check(pmpkg_t *pkg)  					(unsigned long)errors), errors);  	} -	return(errors != 0 ? 1 : 0); +	return (errors != 0 ? 1 : 0);  }  static int display(pmpkg_t *pkg) @@ -466,7 +466,7 @@ static int display(pmpkg_t *pkg)  			printf("%s\n", alpm_pkg_get_name(pkg));  		}  	} -	return(ret); +	return ret;  }  int pacman_query(alpm_list_t *targets) @@ -482,13 +482,13 @@ int pacman_query(alpm_list_t *targets)  	/* search for a package */  	if(config->op_q_search) {  		ret = query_search(targets); -		return(ret); +		return ret;  	}  	/* looking for groups */  	if(config->group) {  		ret = query_group(targets); -		return(ret); +		return ret;  	}  	if(config->op_q_foreign) { @@ -496,7 +496,7 @@ int pacman_query(alpm_list_t *targets)  		alpm_list_t *sync_dbs = alpm_option_get_syncdbs();  		if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {  			pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n")); -			return(1); +			return 1;  		}  	} @@ -508,7 +508,7 @@ int pacman_query(alpm_list_t *targets)  	if(targets == NULL) {  		if(config->op_q_isfile || config->op_q_owns) {  			pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); -			return(1); +			return 1;  		}  		for(i = alpm_db_get_pkgcache(db_local); i; i = alpm_list_next(i)) { @@ -524,7 +524,7 @@ int pacman_query(alpm_list_t *targets)  		if(!match) {  			ret = 1;  		} -		return(ret); +		return ret;  	}  	/* Second: operations that require target(s) */ @@ -532,7 +532,7 @@ int pacman_query(alpm_list_t *targets)  	/* determine the owner of a file */  	if(config->op_q_owns) {  		ret = query_fileowner(targets); -		return(ret); +		return ret;  	}  	/* operations on named packages in the local DB @@ -570,7 +570,7 @@ int pacman_query(alpm_list_t *targets)  		ret = 1;  	} -	return(ret); +	return ret;  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/remove.c b/src/pacman/remove.c index fb02e242..58e6edd5 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -40,25 +40,25 @@ static int remove_target(char *target)  	if((info = alpm_db_get_pkg(db_local, target)) != NULL) {  		if(alpm_remove_pkg(info) == -1) {  			pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, alpm_strerrorlast()); -			return(-1); +			return -1;  		} -		return(0); +		return 0;  	}  		/* fallback to group */  	pmgrp_t *grp = alpm_db_readgrp(db_local, target);  	if(grp == NULL) {  		pm_fprintf(stderr, PM_LOG_ERROR, "'%s': target not found\n", target); -		return(-1); +		return -1;  	}  	for(p = alpm_grp_get_pkgs(grp); p; p = alpm_list_next(p)) {  		pmpkg_t *pkg = alpm_list_getdata(p);  		if(alpm_remove_pkg(pkg) == -1) {  			pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, alpm_strerrorlast()); -			return(-1); +			return -1;  		}  	} -	return(0); +	return 0;  }  /** @@ -75,12 +75,12 @@ int pacman_remove(alpm_list_t *targets)  	if(targets == NULL) {  		pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); -		return(1); +		return 1;  	}  	/* Step 0: create a new transaction */  	if(trans_init(config->flags) == -1) { -		return(1); +		return 1;  	}  	/* Step 1: add targets to the created transaction */ @@ -173,7 +173,7 @@ cleanup:  	if(trans_release() == -1) {  		retval = 1;  	} -	return(retval); +	return retval;  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 13b65a8f..b12206c4 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -47,7 +47,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) {  	dir = opendir(dbpath);  	if(dir == NULL) {  		pm_fprintf(stderr, PM_LOG_ERROR, _("could not access database directory\n")); -		return(1); +		return 1;  	}  	syncdbs = alpm_option_get_syncdbs(); @@ -84,7 +84,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) {  				pm_fprintf(stderr, PM_LOG_ERROR,  					_("could not remove %s\n"), path);  				closedir(dir); -				return(1); +				return 1;  			}  			continue;  		} @@ -110,12 +110,12 @@ static int sync_cleandb(const char *dbpath, int keep_used) {  				pm_fprintf(stderr, PM_LOG_ERROR,  					_("could not remove %s\n"), path);  				closedir(dir); -				return(1); +				return 1;  			}  		}  	}  	closedir(dir); -	return(0); +	return 0;  }  static int sync_cleandb_all(void) { @@ -126,7 +126,7 @@ static int sync_cleandb_all(void) {  	dbpath = alpm_option_get_dbpath();  	printf(_("Database directory: %s\n"), dbpath);  	if(!yesno(_("Do you want to remove unused repositories?"))) { -		return(0); +		return 0;  	}  	/* The sync dbs were previously put in dbpath/ but are now in dbpath/sync/.  	 * We will clean everything in dbpath/ except local/, sync/ and db.lck, and @@ -137,7 +137,7 @@ static int sync_cleandb_all(void) {  	ret += sync_cleandb(newdbpath, 1);  	printf(_("Database directory cleaned up\n")); -	return(ret); +	return ret;  }  static int sync_cleancache(int level) @@ -165,12 +165,12 @@ static int sync_cleancache(int level)  			printf(_("  All current sync database packages\n"));  		}  		if(!yesno(_("Do you want to remove all other packages from cache?"))) { -			return(0); +			return 0;  		}  		printf(_("removing old packages from cache...\n"));  	} else {  		if(!noyes(_("Do you want to remove ALL files from cache?"))) { -			return(0); +			return 0;  		}  		printf(_("removing all files from cache...\n"));  	} @@ -258,7 +258,7 @@ static int sync_cleancache(int level)  		closedir(dir);  	} -	return(ret); +	return ret;  }  static int sync_synctree(int level, alpm_list_t *syncs) @@ -267,7 +267,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)  	int success = 0, ret;  	if(trans_init(0) == -1) { -		return(0); +		return 0;  	}  	for(i = syncs; i; i = alpm_list_next(i)) { @@ -286,7 +286,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)  	}  	if(trans_release() == -1) { -		return(0); +		return 0;  	}  	/* We should always succeed if at least one DB was upgraded - we may possibly  	 * fail later with unresolved deps, but that should be rare, and would be @@ -295,7 +295,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)  	if(!success) {  		pm_fprintf(stderr, PM_LOG_ERROR, _("failed to synchronize any databases\n"));  	} -	return(success > 0); +	return (success > 0);  }  static void print_installed(pmdb_t *db_local, pmpkg_t *pkg) @@ -384,7 +384,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)  		}  	} -	return(!found); +	return !found;  }  static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) @@ -432,7 +432,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)  		}  	} -	return(0); +	return 0;  }  static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) @@ -466,7 +466,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)  				if(!db) {  					pm_fprintf(stderr, PM_LOG_ERROR,  						_("repository '%s' does not exist\n"), repo); -					return(1); +					return 1;  				}  				for(k = alpm_db_get_pkgcache(db); k; k = alpm_list_next(k)) { @@ -517,7 +517,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)  		}  	} -	return(ret); +	return ret;  }  static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) @@ -543,7 +543,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)  				pm_fprintf(stderr, PM_LOG_ERROR,  					_("repository \"%s\" was not found.\n"),repo);  				alpm_list_free(ls); -				return(1); +				return 1;  			}  			ls = alpm_list_add(ls, db); @@ -573,7 +573,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)  		alpm_list_free(ls);  	} -	return(0); +	return 0;  }  static alpm_list_t *syncfirst(void) { @@ -591,7 +591,7 @@ static alpm_list_t *syncfirst(void) {  		}  	} -	return(res); +	return res;  }  static pmdb_t *get_db(const char *dbname) @@ -600,10 +600,10 @@ static pmdb_t *get_db(const char *dbname)  	for(i = alpm_option_get_syncdbs(); i; i = i->next) {  		pmdb_t *db = i->data;  		if(strcmp(alpm_db_get_name(db), dbname) == 0) { -			return(db); +			return db;  		}  	} -	return(NULL); +	return NULL;  }  static int process_pkg(pmpkg_t *pkg) @@ -615,14 +615,14 @@ static int process_pkg(pmpkg_t *pkg)  				|| pm_errno == PM_ERR_PKG_IGNORED) {  			/* just skip duplicate or ignored targets */  			pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg)); -			return(0); +			return 0;  		} else {  			pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg),  					alpm_strerrorlast()); -			return(1); +			return 1;  		}  	} -	return(0); +	return 0;  }  static int process_group(alpm_list_t *dbs, char *group) @@ -634,7 +634,7 @@ static int process_group(alpm_list_t *dbs, char *group)  	if(!count) {  		pm_fprintf(stderr, PM_LOG_ERROR, _("target not found: %s\n"), group); -		return(1); +		return 1;  	} @@ -668,7 +668,7 @@ static int process_group(alpm_list_t *dbs, char *group)  	}  cleanup:  	alpm_list_free(pkgs); -	return(ret); +	return ret;  }  static int process_targname(alpm_list_t *dblist, char *targname) @@ -679,14 +679,14 @@ static int process_targname(alpm_list_t *dblist, char *targname)  	if(pm_errno == PM_ERR_PKG_IGNORED) {  			pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), targname);  			pm_errno = 0; -			return(0); +			return 0;  	}  	if(pkg) { -		return(process_pkg(pkg)); +		return process_pkg(pkg);  	}  	/* fallback on group */ -	return(process_group(dblist, targname)); +	return process_group(dblist, targname);  }  static int process_target(char *target) @@ -721,7 +721,7 @@ static int process_target(char *target)  	}  cleanup:  	free(targstring); -	return(ret); +	return ret;  }  static int sync_trans(alpm_list_t *targets) @@ -733,7 +733,7 @@ static int sync_trans(alpm_list_t *targets)  	/* Step 1: create a new transaction... */  	if(trans_init(config->flags) == -1) { -		return(1); +		return 1;  	}  	/* process targets */ @@ -873,7 +873,7 @@ cleanup:  		retval = 1;  	} -	return(retval); +	return retval;  }  int pacman_sync(alpm_list_t *targets) @@ -885,7 +885,7 @@ int pacman_sync(alpm_list_t *targets)  		int ret = 0;  		if(trans_init(0) == -1) { -			return(1); +			return 1;  		}  		ret += sync_cleancache(config->op_s_clean); @@ -896,14 +896,14 @@ int pacman_sync(alpm_list_t *targets)  			ret++;  		} -		return(ret); +		return ret;  	}  	/* ensure we have at least one valid sync db set up */  	sync_dbs = alpm_option_get_syncdbs();  	if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {  		pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n")); -		return(1); +		return 1;  	}  	if(config->op_s_sync) { @@ -911,40 +911,40 @@ int pacman_sync(alpm_list_t *targets)  		printf(_(":: Synchronizing package databases...\n"));  		alpm_logaction("synchronizing package lists\n");  		if(!sync_synctree(config->op_s_sync, sync_dbs)) { -			return(1); +			return 1;  		}  	}  	/* search for a package */  	if(config->op_s_search) { -		return(sync_search(sync_dbs, targets)); +		return sync_search(sync_dbs, targets);  	}  	/* look for groups */  	if(config->group) { -		return(sync_group(config->group, sync_dbs, targets)); +		return sync_group(config->group, sync_dbs, targets);  	}  	/* get package info */  	if(config->op_s_info) { -		return(sync_info(sync_dbs, targets)); +		return sync_info(sync_dbs, targets);  	}  	/* get a listing of files in sync DBs */  	if(config->op_q_list) { -		return(sync_list(sync_dbs, targets)); +		return sync_list(sync_dbs, targets);  	}  	if(targets == NULL) {  		if(config->op_s_upgrade) {  			/* proceed */  		} else if(config->op_s_sync) { -			return(0); +			return 0;  		} else {  			/* don't proceed here unless we have an operation that doesn't require a  			 * target list */  			pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); -			return(1); +			return 1;  		}  	} @@ -979,7 +979,7 @@ int pacman_sync(alpm_list_t *targets)  	int ret = sync_trans(targs);  	FREELIST(targs); -	return(ret); +	return ret;  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 8cd29da0..5b894001 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -46,7 +46,7 @@ int pacman_upgrade(alpm_list_t *targets)  	if(targets == NULL) {  		pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n")); -		return(1); +		return 1;  	}  	/* Check for URL targets and process them @@ -57,7 +57,7 @@ int pacman_upgrade(alpm_list_t *targets)  			if(str == NULL) {  				pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",  						(char *)i->data, alpm_strerrorlast()); -				return(1); +				return 1;  			} else {  				free(i->data);  				i->data = str; @@ -67,7 +67,7 @@ int pacman_upgrade(alpm_list_t *targets)  	/* Step 1: create a new transaction */  	if(trans_init(config->flags) == -1) { -		return(1); +		return 1;  	}  	/* add targets to the created transaction */ @@ -79,14 +79,14 @@ int pacman_upgrade(alpm_list_t *targets)  			pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",  					targ, alpm_strerrorlast());  			trans_release(); -			return(1); +			return 1;  		}  		if(alpm_add_pkg(pkg) == -1) {  			pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",  					targ, alpm_strerrorlast());  			alpm_pkg_free(pkg);  			trans_release(); -			return(1); +			return 1;  		}  	} @@ -135,7 +135,7 @@ int pacman_upgrade(alpm_list_t *targets)  		}  		trans_release();  		FREELIST(data); -		return(1); +		return 1;  	}  	/* Step 3: perform the installation */ @@ -143,7 +143,7 @@ int pacman_upgrade(alpm_list_t *targets)  	if(config->print) {  		print_packages(alpm_trans_get_add());  		trans_release(); -		return(0); +		return 0;  	}  	/* print targets and ask user confirmation */ @@ -151,7 +151,7 @@ int pacman_upgrade(alpm_list_t *targets)  	if(packages == NULL) { /* we are done */  		printf(_(" there is nothing to do\n"));  		trans_release(); -		return(retval); +		return retval;  	}  	display_targets(alpm_trans_get_remove(), 0);  	display_targets(alpm_trans_get_add(), 1); @@ -159,7 +159,7 @@ int pacman_upgrade(alpm_list_t *targets)  	int confirm = yesno(_("Proceed with installation?"));  	if(!confirm) {  		trans_release(); -		return(retval); +		return retval;  	}  	if(alpm_trans_commit(&data) == -1) { @@ -197,13 +197,13 @@ int pacman_upgrade(alpm_list_t *targets)  		}  		FREELIST(data);  		trans_release(); -		return(1); +		return 1;  	}  	if(trans_release() == -1) {  		retval = 1;  	} -	return(retval); +	return retval;  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/util.c b/src/pacman/util.c index 83368085..558d6f8f 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -68,9 +68,9 @@ int trans_init(pmtransflag_t flags)  			fprintf(stderr, _("  try running pacman-db-upgrade\n"));  		} -		return(-1); +		return -1;  	} -	return(0); +	return 0;  }  int trans_release(void) @@ -78,25 +78,25 @@ int trans_release(void)  	if(alpm_trans_release() == -1) {  		pm_fprintf(stderr, PM_LOG_ERROR, _("failed to release transaction (%s)\n"),  				alpm_strerrorlast()); -		return(-1); +		return -1;  	} -	return(0); +	return 0;  }  int needs_root(void)  {  	switch(config->op) {  		case PM_OP_DATABASE: -			return(1); +			return 1;  		case PM_OP_UPGRADE:  		case PM_OP_REMOVE: -			return(!config->print); +			return !config->print;  		case PM_OP_SYNC: -			return(config->op_s_clean || config->op_s_sync || +			return (config->op_s_clean || config->op_s_sync ||  					(!config->group && !config->op_s_info && !config->op_q_list &&  					 !config->op_s_search && !config->print));  		default: -			return(0); +			return 0;  	}  } @@ -125,24 +125,24 @@ int rmrf(const char *path)  	DIR *dirp;  	if(!unlink(path)) { -		return(0); +		return 0;  	} else {  		if(errno == ENOENT) { -			return(0); +			return 0;  		} else if(errno == EPERM) {  			/* fallthrough */  		} else if(errno == EISDIR) {  			/* fallthrough */  		} else if(errno == ENOTDIR) { -			return(1); +			return 1;  		} else {  			/* not a directory */ -			return(1); +			return 1;  		}  		dirp = opendir(path);  		if(!dirp) { -			return(1); +			return 1;  		}  		for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {  			if(dp->d_ino) { @@ -157,7 +157,7 @@ int rmrf(const char *path)  		if(rmdir(path)) {  			errflag++;  		} -		return(errflag); +		return errflag;  	}  } @@ -170,9 +170,9 @@ const char *mbasename(const char *path)  {  	const char *last = strrchr(path, '/');  	if(last) { -		return(last + 1); +		return last + 1;  	} -	return(path); +	return path;  }  /** Parse the dirname of a program from a path. @@ -187,7 +187,7 @@ char *mdirname(const char *path)  	/* null or empty path */  	if(path == NULL || path == '\0') { -		return(strdup(".")); +		return strdup(".");  	}  	ret = strdup(path); @@ -196,11 +196,11 @@ char *mdirname(const char *path)  	if(last != NULL) {  		/* we found a '/', so terminate our string */  		*last = '\0'; -		return(ret); +		return ret;  	}  	/* no slash found */  	free(ret); -	return(strdup(".")); +	return strdup(".");  }  /* output a string, but wrap words properly with a specified indentation @@ -286,7 +286,7 @@ char *strtrim(char *str)  	if(str == NULL || *str == '\0') {  		/* string is empty, so we're done. */ -		return(str); +		return str;  	}  	while(isspace((unsigned char)*pch)) { @@ -298,7 +298,7 @@ char *strtrim(char *str)  	/* check if there wasn't anything but whitespace in the string. */  	if(*str == '\0') { -		return(str); +		return str;  	}  	pch = (str + (strlen(str) - 1)); @@ -307,7 +307,7 @@ char *strtrim(char *str)  	}  	*++pch = '\0'; -	return(str); +	return str;  }  /* Replace all occurances of 'needle' with 'replace' in 'str', returning @@ -321,7 +321,7 @@ char *strreplace(const char *str, const char *needle, const char *replace)  	size_t newsz;  	if(!str) { -		return(NULL); +		return NULL;  	}  	p = str; @@ -334,7 +334,7 @@ char *strreplace(const char *str, const char *needle, const char *replace)  	/* no occurences of needle found */  	if(!list) { -		return(strdup(str)); +		return strdup(str);  	}  	/* size of new string = size of old string + "number of occurences of needle"  	 * x "size difference between replace and needle" */ @@ -342,7 +342,7 @@ char *strreplace(const char *str, const char *needle, const char *replace)  		alpm_list_count(list) * (replacesz - needlesz);  	newstr = malloc(newsz);  	if(!newstr) { -		return(NULL); +		return NULL;  	}  	*newstr = '\0'; @@ -368,7 +368,7 @@ char *strreplace(const char *str, const char *needle, const char *replace)  	}  	*newp = '\0'; -	return(newstr); +	return newstr;  }  /** Splits a string into a list of strings using the chosen character as @@ -388,7 +388,7 @@ alpm_list_t *strsplit(const char *str, const char splitchar)  	while((str = strchr(str, splitchar))) {  		dup = strndup(prev, (size_t)(str - prev));  		if(dup == NULL) { -			return(NULL); +			return NULL;  		}  		list = alpm_list_add(list, dup); @@ -398,11 +398,11 @@ alpm_list_t *strsplit(const char *str, const char splitchar)  	dup = strdup(prev);  	if(dup == NULL) { -		return(NULL); +		return NULL;  	}  	list = alpm_list_add(list, dup); -	return(list); +	return list;  }  static int string_length(const char *s) @@ -411,7 +411,7 @@ static int string_length(const char *s)  	wchar_t *wcstr;  	if(!s) { -		return(0); +		return 0;  	}  	/* len goes from # bytes -> # chars -> # cols */  	len = strlen(s) + 1; @@ -420,7 +420,7 @@ static int string_length(const char *s)  	len = wcswidth(wcstr, len);  	free(wcstr); -	return(len); +	return len;  }  void string_display(const char *title, const char *string) @@ -568,11 +568,11 @@ static off_t pkg_get_size(pmpkg_t *pkg)  {  	switch(config->op) {  		case PM_OP_SYNC: -			return(alpm_pkg_download_size(pkg)); +			return alpm_pkg_download_size(pkg);  		case PM_OP_UPGRADE: -			return(alpm_pkg_get_size(pkg)); +			return alpm_pkg_get_size(pkg);  		default: -			return(alpm_pkg_get_isize(pkg)); +			return alpm_pkg_get_isize(pkg);  	}  } @@ -588,14 +588,14 @@ static char *pkg_get_location(pmpkg_t *pkg)  			if(dburl) {  				char *pkgurl = NULL;  				pm_asprintf(&pkgurl, "%s/%s", dburl, alpm_pkg_get_filename(pkg)); -				return(pkgurl); +				return pkgurl;  			}  		case PM_OP_UPGRADE: -			return(strdup(alpm_pkg_get_filename(pkg))); +			return strdup(alpm_pkg_get_filename(pkg));  		default:  			string = NULL;  			pm_asprintf(&string, "%s-%s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); -			return(string); +			return string;  	}  } @@ -657,7 +657,7 @@ void print_packages(const alpm_list_t *packages)   * alpm "compare func" signature */  int str_cmp(const void *s1, const void *s2)  { -	return(strcmp(s1, s2)); +	return strcmp(s1, s2);  }  void display_new_optdepends(pmpkg_t *oldpkg, pmpkg_t *newpkg) @@ -726,13 +726,13 @@ static int parseindex(char *s, int *val, int min, int max)  		if(n < min || n > max) {  			fprintf(stderr, _("Invalid value: %d is not between %d and %d\n"),  					n, min, max); -			return(-1); +			return -1;  		}  		*val = n; -		return(0); +		return 0;  	} else {  		fprintf(stderr, _("Invalid number: %s\n"), s); -		return(-1); +		return -1;  	}  } @@ -772,20 +772,20 @@ static int multiselect_parse(char *array, int count, char *response)  		}  		if(parseindex(starts, &start, 1, count) != 0) -			return(-1); +			return -1;  		if(!ends) {  			array[start-1] = include;  		} else {  			if(parseindex(ends, &end, start, count) != 0) -				return(-1); +				return -1;  			for(int d = start; d <= end; d++) {  				array[d-1] = include;  			}  		}  	} -	return(0); +	return 0;  }  int multiselect_question(char *array, int count) @@ -823,7 +823,7 @@ int multiselect_question(char *array, int count)  		}  		break;  	} -	return(0); +	return 0;  }  int select_question(int count) @@ -855,13 +855,13 @@ int select_question(int count)  				int n;  				if(parseindex(response, &n, 1, count) != 0)  					continue; -				return(n-1); +				return (n - 1);  			}  		}  		break;  	} -	return(preset-1); +	return (preset - 1);  } @@ -888,22 +888,22 @@ static int question(short preset, char *fmt, va_list args)  	if(config->noconfirm) {  		fprintf(stream, "\n"); -		return(preset); +		return preset;  	}  	if(fgets(response, sizeof(response), stdin)) {  		strtrim(response);  		if(strlen(response) == 0) { -			return(preset); +			return preset;  		}  		if(strcasecmp(response, _("Y")) == 0 || strcasecmp(response, _("YES")) == 0) { -			return(1); +			return 1;  		} else if (strcasecmp(response, _("N")) == 0 || strcasecmp(response, _("NO")) == 0) { -			return(0); +			return 0;  		}  	} -	return(0); +	return 0;  }  int yesno(char *fmt, ...) @@ -915,7 +915,7 @@ int yesno(char *fmt, ...)  	ret = question(1, fmt, args);  	va_end(args); -	return(ret); +	return ret;  }  int noyes(char *fmt, ...) @@ -927,7 +927,7 @@ int noyes(char *fmt, ...)  	ret = question(0, fmt, args);  	va_end(args); -	return(ret); +	return ret;  }  int pm_printf(pmloglevel_t level, const char *format, ...) @@ -940,7 +940,7 @@ int pm_printf(pmloglevel_t level, const char *format, ...)  	ret = pm_vfprintf(stdout, level, format, args);  	va_end(args); -	return(ret); +	return ret;  }  int pm_fprintf(FILE *stream, pmloglevel_t level, const char *format, ...) @@ -953,7 +953,7 @@ int pm_fprintf(FILE *stream, pmloglevel_t level, const char *format, ...)  	ret = pm_vfprintf(stream, level, format, args);  	va_end(args); -	return(ret); +	return ret;  }  int pm_asprintf(char **string, const char *format, ...) @@ -969,7 +969,7 @@ int pm_asprintf(char **string, const char *format, ...)  	}  	va_end(args); -	return(ret); +	return ret;  }  int pm_vasprintf(char **string, pmloglevel_t level, const char *format, va_list args) @@ -1005,7 +1005,7 @@ int pm_vasprintf(char **string, pmloglevel_t level, const char *format, va_list  	}  	free(msg); -	return(ret); +	return ret;  }  int pm_vfprintf(FILE *stream, pmloglevel_t level, const char *format, va_list args) @@ -1053,7 +1053,7 @@ int pm_vfprintf(FILE *stream, pmloglevel_t level, const char *format, va_list ar  	/* print the message using va_arg list */  	ret = vfprintf(stream, format, args); -	return(ret); +	return ret;  }  #ifndef HAVE_STRNDUP @@ -1062,7 +1062,7 @@ static size_t strnlen(const char *s, size_t max)  {      register const char *p;      for(p = s; *p && max--; ++p); -    return(p - s); +    return (p - s);  }  char *strndup(const char *s, size_t n) @@ -1074,7 +1074,7 @@ char *strndup(const char *s, size_t n)      return NULL;    new[len] = '\0'; -  return (char *) memcpy(new, s, len); +  return (char *)memcpy(new, s, len);  }  #endif | 
