index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/util.c | 88 |
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 430da92a..28cf8e51 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -87,7 +87,7 @@ char* strsep(char** str, const char* delims) int _alpm_makepath(const char *path) { - return(_alpm_makepath_mode(path, 0755)); + return _alpm_makepath_mode(path, 0755); } /* does the same thing as 'mkdir -p' */ @@ -123,7 +123,7 @@ int _alpm_makepath_mode(const char *path, mode_t mode) free(orig); free(incr); umask(oldmask); - return(ret); + return ret; } #define CPBUFSIZE 8 * 1024 @@ -137,12 +137,12 @@ int _alpm_copyfile(const char *src, const char *dest) in = fopen(src, "rb"); if(in == NULL) { - return(1); + return 1; } out = fopen(dest, "wb"); if(out == NULL) { fclose(in); - return(1); + return 1; } CALLOC(buf, (size_t)CPBUFSIZE, (size_t)1, ret = 1; goto cleanup;); @@ -175,7 +175,7 @@ cleanup: fclose(in); fclose(out); FREE(buf); - return(ret); + return ret; } /* Trim whitespace and newlines from a string @@ -186,7 +186,7 @@ char *_alpm_strtrim(char *str) if(*str == '\0') { /* string is empty, so we're done. */ - return(str); + return str; } while(isspace((unsigned char)*pch)) { @@ -198,7 +198,7 @@ char *_alpm_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)); @@ -207,7 +207,7 @@ char *_alpm_strtrim(char *str) } *++pch = '\0'; - return(str); + return str; } /* Compression functions */ @@ -225,12 +225,12 @@ int _alpm_unpack_single(const char *archive, const char *prefix, const char *fn) alpm_list_t *list = NULL; int ret = 0; if(fn == NULL) { - return(1); + return 1; } list = alpm_list_add(list, (void *)fn); ret = _alpm_unpack(archive, prefix, list, 1); alpm_list_free(list); - return(ret); + return ret; } /** @@ -341,7 +341,7 @@ cleanup: if(restore_cwd && chdir(cwd) != 0) { _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno)); } - return(ret); + return ret; } /* does the same thing as 'rm -rf' */ @@ -356,18 +356,18 @@ int _alpm_rmrf(const char *path) if(_alpm_lstat(path, &st) == 0) { if(!S_ISDIR(st.st_mode)) { if(!unlink(path)) { - return(0); + return 0; } else { if(errno == ENOENT) { - return(0); + return 0; } else { - return(1); + return 1; } } } else { dirp = opendir(path); if(!dirp) { - return(1); + return 1; } for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { if(dp->d_ino) { @@ -382,9 +382,9 @@ int _alpm_rmrf(const char *path) errflag++; } } - return(errflag); + return errflag; } - return(0); + return 0; } int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args) @@ -415,7 +415,7 @@ int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args) fflush(f); } - return(ret); + return ret; } int _alpm_run_chroot(const char *root, const char *path, char *const argv[]) @@ -532,7 +532,7 @@ cleanup: _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno)); } - return(retval); + return retval; } int _alpm_ldconfig(const char *root) @@ -550,14 +550,14 @@ int _alpm_ldconfig(const char *root) } } - return(0); + return 0; } /* Helper function for comparing strings using the * alpm "compare func" signature */ int _alpm_str_cmp(const void *s1, const void *s2) { - return(strcmp(s1, s2)); + return strcmp(s1, s2); } /** Find a filename in a registered alpm cachedir. @@ -578,7 +578,7 @@ char *_alpm_filecache_find(const char* filename) if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) { retpath = strdup(path); _alpm_log(PM_LOG_DEBUG, "found cached pkg: %s\n", retpath); - return(retpath); + return retpath; } } /* package wasn't found in any cachedir */ @@ -604,11 +604,11 @@ const char *_alpm_filecache_setup(void) cachedir); if(_alpm_makepath(cachedir) == 0) { _alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir); - return(cachedir); + return cachedir; } } else if(S_ISDIR(buf.st_mode) && (buf.st_mode & S_IWUSR)) { _alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir); - return(cachedir); + return cachedir; } } @@ -617,7 +617,7 @@ const char *_alpm_filecache_setup(void) alpm_option_set_cachedirs(tmp); _alpm_log(PM_LOG_DEBUG, "using cachedir: %s", "/tmp/\n"); _alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n")); - return(alpm_list_getdata(tmp)); + return alpm_list_getdata(tmp); } /** lstat wrapper that treats /path/dirsymlink/ the same as /path/dirsymlink. @@ -641,7 +641,7 @@ int _alpm_lstat(const char *path, struct stat *buf) ret = lstat(newpath, buf); FREE(newpath); - return(ret); + return ret; } #ifdef HAVE_LIBSSL @@ -652,11 +652,11 @@ static int md5_file(const char *path, unsigned char output[16]) MD5_CTX ctx; unsigned char *buf; - CALLOC(buf, 8192, sizeof(unsigned char), return(1)); + CALLOC(buf, 8192, sizeof(unsigned char), RET_ERR(PM_ERR_MEMORY, 1)); if((f = fopen(path, "rb")) == NULL) { free(buf); - return(1); + return 1; } MD5_Init(&ctx); @@ -672,11 +672,11 @@ static int md5_file(const char *path, unsigned char output[16]) if(ferror(f) != 0) { fclose(f); - return(2); + return 2; } fclose(f); - return(0); + return 0; } #endif @@ -693,7 +693,7 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename) ALPM_LOG_FUNC; - ASSERT(filename != NULL, return(NULL)); + ASSERT(filename != NULL, return NULL); /* allocate 32 chars plus 1 for null */ md5sum = calloc(33, sizeof(char)); @@ -712,7 +712,7 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename) md5sum[32] = '\0'; _alpm_log(PM_LOG_DEBUG, "md5(%s) = %s\n", filename, md5sum); - return(md5sum); + return md5sum; } int _alpm_test_md5sum(const char *filepath, const char *md5sum) @@ -731,7 +731,7 @@ int _alpm_test_md5sum(const char *filepath, const char *md5sum) } FREE(md5sum2); - return(ret); + return ret; } /* Note: does NOT handle sparse files on purpose for speed. */ @@ -804,7 +804,7 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b) b->line_offset[len] = '\0'; b->block_offset = ++i; /* this is the main return point; from here you can read b->line */ - return(ARCHIVE_OK); + return ARCHIVE_OK; } else { /* we've looked through the whole block but no newline, copy it */ size_t len = (size_t)(b->block + b->block_size - b->block_offset); @@ -819,7 +819,7 @@ cleanup: int ret = b->ret; FREE(b->line); memset(b, 0, sizeof(b)); - return(ret); + return ret; } } @@ -833,7 +833,7 @@ int _alpm_splitname(const char *target, pmpkg_t *pkg) const char *version, *end; if(target == NULL || pkg == NULL) { - return(-1); + return -1; } end = target + strlen(target); @@ -847,7 +847,7 @@ int _alpm_splitname(const char *target, pmpkg_t *pkg) for(version = end - 1; *version && *version != '-'; version--); for(version = version - 1; *version && *version != '-'; version--); if(*version != '-' || version == target) { - return(-1); + return -1; } /* copy into fields and return */ @@ -865,7 +865,7 @@ int _alpm_splitname(const char *target, pmpkg_t *pkg) STRNDUP(pkg->name, target, version - target, RET_ERR(PM_ERR_MEMORY, -1)); pkg->name_hash = _alpm_hash_sdbm(pkg->name); - return(0); + return 0; } /** @@ -880,13 +880,13 @@ unsigned long _alpm_hash_sdbm(const char *str) int c; if(!str) { - return(hash); + return hash; } while((c = *str++)) { hash = c + (hash << 6) + (hash << 16) - hash; } - return(hash); + return hash; } long _alpm_parsedate(const char *line) @@ -897,9 +897,9 @@ long _alpm_parsedate(const char *line) setlocale(LC_TIME, "C"); strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm); setlocale(LC_TIME, ""); - return(mktime(&tmp_tm)); + return mktime(&tmp_tm); } - return(atol(line)); + return atol(line); } #ifndef HAVE_STRNDUP @@ -908,7 +908,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) @@ -920,7 +920,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 |