aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2019-03-27 21:18:20 +0100
committerFabian Groffen <grobian@gentoo.org>2019-03-27 21:18:20 +0100
commit3cf77d19bd7f3abd323e4f148f73575cee8ac85b (patch)
tree145f4d97eef00fe3691ad4276d5d1b267b74364b
parentconfigure: ignore expansion undefined warnings for gnulib (diff)
downloadportage-utils-3cf77d19bd7f3abd323e4f148f73575cee8ac85b.tar.gz
portage-utils-3cf77d19bd7f3abd323e4f148f73575cee8ac85b.tar.bz2
portage-utils-3cf77d19bd7f3abd323e4f148f73575cee8ac85b.zip
q: fix various issues on Linux systems
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r--libq/contents.c1
-rw-r--r--libq/xpak.c2
-rw-r--r--libq/xsystem.c7
-rw-r--r--main.c4
-rw-r--r--main.h1
-rw-r--r--q.c1
-rw-r--r--qcache.c2
-rw-r--r--qgrep.c15
-rw-r--r--qlop.c1
-rw-r--r--qmerge.c10
-rw-r--r--qpkg.c4
-rw-r--r--qsearch.c1
-rw-r--r--qtegrity.c3
-rw-r--r--quse.c1
14 files changed, 35 insertions, 18 deletions
diff --git a/libq/contents.c b/libq/contents.c
index 41929d06..3e719a69 100644
--- a/libq/contents.c
+++ b/libq/contents.c
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include "contents.h"
diff --git a/libq/xpak.c b/libq/xpak.c
index 09b58bd0..27858997 100644
--- a/libq/xpak.c
+++ b/libq/xpak.c
@@ -258,7 +258,7 @@ _xpak_add_file(
/* the xpak format can only store files whose size is a 32bit int
* so we have to make sure we don't store a big file */
if (in_len != st->st_size) {
- warnf("File is too big: %"PRIu64, (uint64_t)st->st_size);
+ warnf("File is too big: %zu", (size_t)st->st_size);
fclose(fin);
goto fake_data_len;
}
diff --git a/libq/xsystem.c b/libq/xsystem.c
index 1cc5cad7..e11172e6 100644
--- a/libq/xsystem.c
+++ b/libq/xsystem.c
@@ -6,12 +6,15 @@
*/
#include "main.h"
-#include "xasprintf.h"
-#include "xsystem.h"
#include <stdlib.h>
#include <sys/wait.h>
#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "xasprintf.h"
+#include "xsystem.h"
void xsystem(const char *command)
{
diff --git a/main.c b/main.c
index 1da04fee..7e561010 100644
--- a/main.c
+++ b/main.c
@@ -448,7 +448,7 @@ read_portage_env_file(const char *configroot, const char *file, env_vars vars[])
if ((dentslen = scandir(buf, &dents, NULL, alphasort)) > 0) {
int di;
struct dirent *d;
- char npath[_Q_PATH_MAX];
+ char npath[_Q_PATH_MAX * 2];
/* recurse through all files */
for (di = 0; di < dentslen; di++) {
@@ -858,7 +858,7 @@ initialize_flat(const char *overlay, int cache_type, bool force)
if (pkg_cnt < 0)
continue;
for (c = 0; c < pkg_cnt; c++) {
- char de[_Q_PATH_MAX];
+ char de[_Q_PATH_MAX * 2];
snprintf(de, sizeof(de), "%s/%s",
category[i]->d_name, pn[c]->d_name);
diff --git a/main.h b/main.h
index 958efa62..32c995f8 100644
--- a/main.h
+++ b/main.h
@@ -15,6 +15,7 @@
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
diff --git a/q.c b/q.c
index a4a943ea..1e180de4 100644
--- a/q.c
+++ b/q.c
@@ -10,6 +10,7 @@
#include "main.h"
#include "applets.h"
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/qcache.c b/qcache.c
index 29b10afe..f3252d76 100644
--- a/qcache.c
+++ b/qcache.c
@@ -805,7 +805,7 @@ qcache_stats(qcache_data *data)
#endif
{
struct stat s;
- char spath[_Q_PATH_MAX];
+ char spath[_Q_PATH_MAX * 2];
snprintf(spath, sizeof(spath), "%s/%s", catpath, de->d_name);
if (lstat(spath, &s) != 0)
continue;
diff --git a/qgrep.c b/qgrep.c
index da38f403..fdabf9cc 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -223,7 +223,12 @@ qgrep_print_before_context(qgrep_buf_t *current, const char num_lines_before,
/* Yield the path of one of the installed ebuilds (from VDB). */
static char *
-get_next_installed_ebuild(char *ebuild_path, DIR *vdb_dir, struct dirent **cat_dirent_pt, DIR **cat_dir_pt)
+get_next_installed_ebuild(
+ char *ebuild_path,
+ size_t ebuild_path_len,
+ DIR *vdb_dir,
+ struct dirent **cat_dirent_pt,
+ DIR **cat_dir_pt)
{
struct dirent *pkg_dirent = NULL;
if (*cat_dirent_pt == NULL || *cat_dir_pt == NULL)
@@ -233,7 +238,7 @@ get_next_ebuild_from_category:
goto get_next_category;
if (pkg_dirent->d_name[0] == '.')
goto get_next_ebuild_from_category;
- snprintf(ebuild_path, _Q_PATH_MAX, "%s/%s/%s.ebuild",
+ snprintf(ebuild_path, ebuild_path_len, "%s/%s/%s.ebuild",
(*cat_dirent_pt)->d_name, pkg_dirent->d_name, pkg_dirent->d_name);
return ebuild_path;
get_next_category:
@@ -260,7 +265,7 @@ int qgrep_main(int argc, char **argv)
DIR *vdb_dir = NULL;
DIR *cat_dir = NULL;
struct dirent *dentry = NULL;
- char ebuild[_Q_PATH_MAX];
+ char ebuild[_Q_PATH_MAX * 4];
char name[_Q_PATH_MAX * 2];
char *label;
int reflags = 0;
@@ -420,8 +425,8 @@ int qgrep_main(int argc, char **argv)
&& snprintf(ebuild, sizeof(ebuild),
"eclass/%s", dentry->d_name))
: (do_installed
- ? (get_next_installed_ebuild(ebuild, vdb_dir,
- &dentry, &cat_dir) != NULL)
+ ? (get_next_installed_ebuild(ebuild, sizeof(ebuild),
+ vdb_dir, &dentry, &cat_dir) != NULL)
: (fgets(ebuild, sizeof(ebuild), fp) != NULL)))
{
FILE *newfp;
diff --git a/qlop.c b/qlop.c
index b8038b4e..b6970d0c 100644
--- a/qlop.c
+++ b/qlop.c
@@ -15,6 +15,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
+#include <limits.h>
#include "atom.h"
#include "eat_file.h"
diff --git a/qmerge.c b/qmerge.c
index 81da0b14..97726db6 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -850,13 +850,13 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
int fd_srcf, fd_dstf;
unsigned char *hash;
const char *tmpname, *dname;
- char buf[_Q_PATH_MAX];
+ char buf[_Q_PATH_MAX * 2];
/* syntax: obj filename hash mtime */
hash = hash_file_at(subfd_src, name, HASH_MD5);
if (!pretend)
- fprintf(contents, "obj %s %s %"PRIu64"\n",
- cpath, hash, (uint64_t)st.st_mtime);
+ fprintf(contents, "obj %s %s %zu""\n",
+ cpath, hash, (size_t)st.st_mtime);
free(hash);
/* Check CONFIG_PROTECT */
@@ -954,8 +954,8 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
/* syntax: sym src -> dst mtime */
if (!pretend)
- fprintf(contents, "sym %s -> %s %"PRIu64"\n",
- cpath, sym, (uint64_t)st.st_mtime);
+ fprintf(contents, "sym %s -> %s %zu\n",
+ cpath, sym, (size_t)st.st_mtime);
qprintf("%s>>>%s %s%s -> %s%s\n", GREEN, NORM,
CYAN, cpath, sym, NORM);
*objs = add_set(cpath, *objs);
diff --git a/qpkg.c b/qpkg.c
index 3ff45071..37f1cb71 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -77,7 +77,7 @@ qpkg_clean_dir(char *dirp, set *vdb)
set *ll = NULL;
struct dirent **fnames;
int i, count;
- char buf[_Q_PATH_MAX];
+ char buf[_Q_PATH_MAX * 2];
struct stat st;
uint64_t num_all_bytes = 0;
size_t disp_units = 0;
@@ -186,7 +186,7 @@ qpkg_clean(char *dirp)
num_all_bytes = qpkg_clean_dir(dirp, vdb);
for (i = 0; i < count; i++) {
- char buf[_Q_PATH_MAX];
+ char buf[_Q_PATH_MAX * 2];
snprintf(buf, sizeof(buf), "%s/%s", dirp, dnames[i]->d_name);
num_all_bytes += qpkg_clean_dir(buf, vdb);
}
diff --git a/qsearch.c b/qsearch.c
index 5ae68bcc..f543b8ad 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -11,6 +11,7 @@
#include "applets.h"
#include <stdio.h>
+#include <unistd.h>
#include <string.h>
#include <xalloc.h>
#include <sys/types.h>
diff --git a/qtegrity.c b/qtegrity.c
index 2e3b8592..70a99d5f 100644
--- a/qtegrity.c
+++ b/qtegrity.c
@@ -10,8 +10,11 @@
#include "main.h"
#include "applets.h"
+#include <stdio.h>
+#include <unistd.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <signal.h>
#include <fcntl.h>
diff --git a/quse.c b/quse.c
index 62ae1665..c93be873 100644
--- a/quse.c
+++ b/quse.c
@@ -11,6 +11,7 @@
#include "applets.h"
#include <stdio.h>
+#include <unistd.h>
#include <string.h>
#include <xalloc.h>
#include <sys/types.h>