summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-07-06 18:11:55 +0200
committerDan McGee <dan@archlinux.org>2007-07-06 18:11:55 +0200
commit15e1ce2e709e0a16dd54ea3b5eaab0003e32b62d (patch)
treee18b7ff6c79c6c7a81c64caab9d7cb8f80a28274 /lib/libalpm
parent6b7b9743181078aa7152daffdfc1eaeb46304c0f (diff)
downloadpacman-15e1ce2e709e0a16dd54ea3b5eaab0003e32b62d.tar.gz
pacman-15e1ce2e709e0a16dd54ea3b5eaab0003e32b62d.tar.xz
Various small fixes as suggested by some static code checkers
I ran flawfinder and sparse over the pacman source code and found a few things that were worth fixing (and were quick fixes). Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c7
-rw-r--r--lib/libalpm/alpm.c4
-rw-r--r--lib/libalpm/alpm.h2
-rw-r--r--lib/libalpm/util.c8
4 files changed, 7 insertions, 14 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index a8da745c..870d1f8c 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -23,13 +23,6 @@
* USA.
*/
-#if defined(__APPLE__) || defined(__OpenBSD__)
-#include <sys/syslimits.h>
-#endif
-#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__sun__)
-#include <sys/stat.h>
-#endif
-
#include "config.h"
#include <stdlib.h>
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 3b4a089c..dc5ab649 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -44,7 +44,7 @@ enum _pmerrno_t pm_errno SYMEXPORT;
* functions are called.
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int SYMEXPORT alpm_initialize()
+int SYMEXPORT alpm_initialize(void)
{
ASSERT(handle == NULL, RET_ERR(PM_ERR_HANDLE_NOT_NULL, -1));
@@ -59,7 +59,7 @@ int SYMEXPORT alpm_initialize()
/** Release the library. This should be the last alpm call you make.
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int SYMEXPORT alpm_release()
+int SYMEXPORT alpm_release(void)
{
int dbs_left = 0;
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index d1363803..a7fcb5c2 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -56,7 +56,7 @@ typedef struct __pmgraph_t pmgraph_t;
* Library
*/
-int alpm_initialize();
+int alpm_initialize(void);
int alpm_release(void);
/*
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 17872429..72c17bf9 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -85,7 +85,7 @@ char *mkdtemp(char *template)
/* Save template */
(void) strcpy(t, template);
for (; ; ) {
- r = mktemp(template);
+ r = mkstemp(template);
if (*r == '\0')
return (NULL);
@@ -156,21 +156,21 @@ int _alpm_copyfile(const char *src, const char *dest)
while((len = fread(buf, 1, 4096, in))) {
fwrite(buf, 1, len, out);
}
-
fclose(in);
- fclose(out);
/* chmod dest to permissions of src, as long as it is not a symlink */
struct stat statbuf;
if(!stat(src, &statbuf)) {
if(! S_ISLNK(statbuf.st_mode)) {
- chmod(dest, statbuf.st_mode);
+ fchmod(fileno(out), statbuf.st_mode);
}
} else {
/* stat was unsuccessful */
+ fclose(out);
return(1);
}
+ fclose(out);
return(0);
}