New upstream version 0.31.3.
This includes all the previous upstream patches, and reverts the check which broke processing of PE binaries.
This commit is contained in:
parent
86a1ed311e
commit
f943752186
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ icoutils-0.29.1.tar.bz2
|
||||
/icoutils-0.31.0.tar.bz2
|
||||
/icoutils-0.31.1.tar.bz2
|
||||
/icoutils-0.31.2.tar.bz2
|
||||
/icoutils-0.31.3.tar.bz2
|
||||
|
@ -1,32 +0,0 @@
|
||||
From 559285981565943d63426555a422a420b26522c6 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Fri, 10 Mar 2017 12:15:42 +0000
|
||||
Subject: [PATCH] Revert "Add additional sanity checks to do_resource(). Found
|
||||
by Jerzy Kramarz <op7ica@gmail.com>."
|
||||
|
||||
This reverts commit 8040f36e88baef653fd9896714dc27c239485556.
|
||||
---
|
||||
wrestool/restable.c | 4 ----
|
||||
1 file changed, 4 deletions(-)
|
||||
|
||||
diff --git a/wrestool/restable.c b/wrestool/restable.c
|
||||
index fd0ba49..f14dddf 100644
|
||||
--- a/wrestool/restable.c
|
||||
+++ b/wrestool/restable.c
|
||||
@@ -87,13 +87,9 @@ do_resources_recurs (WinLibrary *fi, WinResource *base, WinResource *type_wr,
|
||||
wr = list_resources (fi, base, &rescnt);
|
||||
if (wr == NULL)
|
||||
return;
|
||||
- if (!check_offset(fi->memory, fi->total_size, fi->name, &wr[0], sizeof(WinResource)))
|
||||
- return;
|
||||
|
||||
/* process each resource listed */
|
||||
for (c = 0 ; c < rescnt ; c++) {
|
||||
- if (!check_offset(fi->memory, fi->total_size, fi->name, &wr[c], sizeof(WinResource)))
|
||||
- break;
|
||||
/* (over)write the corresponding WinResource holder with the current */
|
||||
memcpy(WINRESOURCE_BY_LEVEL(wr[c].level), wr+c, sizeof(WinResource));
|
||||
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,39 +0,0 @@
|
||||
From b44434e2224b8cd3ee76dcad641eb03cc6c9cbdd Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 12:10:28 +0000
|
||||
Subject: [PATCH 01/26] wrestool: Fix misleading indentation.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
In GCC 7:
|
||||
|
||||
main.c: In function ‘main’:
|
||||
main.c:243:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
|
||||
if (c == EOF)
|
||||
^~
|
||||
main.c:246:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
|
||||
switch (c) {
|
||||
^~~~~~
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
wrestool/main.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wrestool/main.c b/wrestool/main.c
|
||||
index 0e3f286..a5c6688 100644
|
||||
--- a/wrestool/main.c
|
||||
+++ b/wrestool/main.c
|
||||
@@ -243,7 +243,7 @@ main (int argc, char **argv)
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
- switch (c) {
|
||||
+ switch (c) {
|
||||
case 't': arg_type = optarg; break;
|
||||
case 'n': arg_name = optarg; break;
|
||||
case 'L': arg_language = optarg; break;
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,41 +0,0 @@
|
||||
From a1ba8e23856b980a7bdbd35e955a7d7bb12106be Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 12:11:27 +0000
|
||||
Subject: [PATCH 02/26] gitignore: Use git's pattern matching to make this
|
||||
simpler.
|
||||
|
||||
This makes no semantic change to the gitignore file.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
.gitignore | 19 ++++++++-----------
|
||||
1 file changed, 8 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 435d1ba..e4c8e1f 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -1,12 +1,9 @@
|
||||
-aclocal.m4
|
||||
-autom4te.cache/
|
||||
-common/Makefile.in
|
||||
-config.h.in
|
||||
-config.h.in~
|
||||
-configure
|
||||
-extresso/Makefile.in
|
||||
-icotool/Makefile.in
|
||||
-lib/Makefile.in
|
||||
-wrestool/Makefile.in
|
||||
+*~
|
||||
+
|
||||
Makefile.in
|
||||
-mkinstalldirs
|
||||
+
|
||||
+/aclocal.m4
|
||||
+/autom4te.cache
|
||||
+/config.h.in
|
||||
+/configure
|
||||
+/mkinstalldirs
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,44 +0,0 @@
|
||||
From 102c8319f84bd8f0af5855365f36d58b1e94d556 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 12:13:44 +0000
|
||||
Subject: [PATCH 03/26] gitignore: Ignore most generated files.
|
||||
|
||||
Ignore most of the generated files in a git checkout.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
.gitignore | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index e4c8e1f..0067f39 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -1,9 +1,23 @@
|
||||
*~
|
||||
+*.o
|
||||
+*.a
|
||||
|
||||
+.deps
|
||||
+Makefile
|
||||
Makefile.in
|
||||
|
||||
/aclocal.m4
|
||||
/autom4te.cache
|
||||
+/config.h
|
||||
/config.h.in
|
||||
+/config.log
|
||||
+/config.status
|
||||
/configure
|
||||
+/extresso/extresso
|
||||
+/extresso/genresscript
|
||||
+/icotool/icotool
|
||||
+/icoutils.spec
|
||||
/mkinstalldirs
|
||||
+/po/POTFILES
|
||||
+/stamp-h1
|
||||
+/wrestool/wrestool
|
||||
\ No newline at end of file
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,33 +0,0 @@
|
||||
From 4b83e0d7668b26490271290af2e96898535d1680 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 12:14:56 +0000
|
||||
Subject: [PATCH 04/26] bootstrap: Use 'set -e' to check for errors.
|
||||
|
||||
Using 'set -e' we can avoid writing everything on a single
|
||||
line and using &&.
|
||||
|
||||
This makes no semantic change to the file.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
bootstrap | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/bootstrap b/bootstrap
|
||||
index 0f174ee..816fd63 100755
|
||||
--- a/bootstrap
|
||||
+++ b/bootstrap
|
||||
@@ -1,3 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
-aclocal -I m4 && autoheader && libtoolize --force -c && automake -a -c && autoconf
|
||||
+set -e
|
||||
+
|
||||
+aclocal -I m4
|
||||
+autoheader
|
||||
+libtoolize --force -c
|
||||
+automake -a -c
|
||||
+autoconf
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,83 +0,0 @@
|
||||
From a80b70d60112354fc53c79df97c7a359ebff9c9e Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 12:23:38 +0000
|
||||
Subject: [PATCH 05/26] bootstrap: Run gnulib-tool if available.
|
||||
|
||||
For most people using icoutils from git, compilation won't work unless
|
||||
they update gnulib modules. This runs gnulib-tool from ../gnulib or
|
||||
another directory (pointed to by $GNULIB_SRCDIR) or else prints
|
||||
instructions on how to update gnulib modules.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
bootstrap | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 53 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/bootstrap b/bootstrap
|
||||
index 816fd63..dce9299 100755
|
||||
--- a/bootstrap
|
||||
+++ b/bootstrap
|
||||
@@ -1,7 +1,59 @@
|
||||
-#!/bin/sh
|
||||
+#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
+GNULIB_SRCDIR=${GNULIB_SRCDIR:-../gnulib}
|
||||
+gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
|
||||
+
|
||||
+if $gnulib_tool --version >/dev/null 2>&1; then
|
||||
+ echo "Updating gnulib files from $GNULIB_SRCDIR"
|
||||
+
|
||||
+ $gnulib_tool \
|
||||
+ --import \
|
||||
+ --lib=libgnu \
|
||||
+ --source-base=lib \
|
||||
+ --m4-base=m4 \
|
||||
+ --doc-base=. \
|
||||
+ --tests-base=test \
|
||||
+ --aux-dir=build-aux \
|
||||
+ --no-conditional-dependencies \
|
||||
+ --no-libtool \
|
||||
+ --macro-prefix=gl \
|
||||
+ byteswap \
|
||||
+ configmake \
|
||||
+ dirname \
|
||||
+ dup2 \
|
||||
+ getline \
|
||||
+ getopt-gnu \
|
||||
+ gettext \
|
||||
+ gettimeofday \
|
||||
+ lstat \
|
||||
+ malloc-gnu \
|
||||
+ memchr \
|
||||
+ minmax \
|
||||
+ progname \
|
||||
+ stdbool \
|
||||
+ stdint \
|
||||
+ strcase \
|
||||
+ strdup-posix \
|
||||
+ strerror \
|
||||
+ strndup \
|
||||
+ strstr \
|
||||
+ vasprintf \
|
||||
+ version-etc \
|
||||
+ xalloc \
|
||||
+ xalloc-die \
|
||||
+ xvasprintf
|
||||
+else
|
||||
+ echo "***"
|
||||
+ echo "Warning: Not updating gnulib files"
|
||||
+ echo "***"
|
||||
+ echo "If you get errors in the lib/ directory, then check out gnulib"
|
||||
+ echo "from git and set \$GNULIB_SRCDIR to point to that directory."
|
||||
+ echo "If you have gnulib in ../gnulib then it will be used automatically."
|
||||
+ echo "***"
|
||||
+fi
|
||||
+
|
||||
aclocal -I m4
|
||||
autoheader
|
||||
libtoolize --force -c
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,124 +0,0 @@
|
||||
From c7a3146a6c9c62a4103ec341bceccdb3c96d4019 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 12:34:22 +0000
|
||||
Subject: [PATCH 06/26] configure: Enable many more warnings and add
|
||||
--enable-werror.
|
||||
|
||||
Using the gnulib manywarnings module, enable many more GCC warnings.
|
||||
|
||||
Add the ./configure --enable-werror flag so that these warnings can be
|
||||
turned into hard errors. Only upstream developers should use this, it
|
||||
should not be used for downstream, distro and production builds, and
|
||||
it must not be the default.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
bootstrap | 1 +
|
||||
common/Makefile.am | 2 +-
|
||||
configure.ac | 46 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
icotool/Makefile.am | 2 +-
|
||||
wrestool/Makefile.am | 2 +-
|
||||
5 files changed, 50 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/bootstrap b/bootstrap
|
||||
index dce9299..d7e4609 100755
|
||||
--- a/bootstrap
|
||||
+++ b/bootstrap
|
||||
@@ -29,6 +29,7 @@ if $gnulib_tool --version >/dev/null 2>&1; then
|
||||
gettimeofday \
|
||||
lstat \
|
||||
malloc-gnu \
|
||||
+ manywarnings \
|
||||
memchr \
|
||||
minmax \
|
||||
progname \
|
||||
diff --git a/common/Makefile.am b/common/Makefile.am
|
||||
index 82c6ea1..a5bea98 100644
|
||||
--- a/common/Makefile.am
|
||||
+++ b/common/Makefile.am
|
||||
@@ -27,4 +27,4 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/lib \
|
||||
-I$(top_srcdir)/lib
|
||||
|
||||
-AM_CFLAGS = -Wall
|
||||
+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index d4b74ae..760ac2c 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -23,6 +23,52 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||
# Gnulib
|
||||
gl_INIT
|
||||
|
||||
+# --enable-werror option for developers.
|
||||
+AC_ARG_ENABLE([werror],
|
||||
+ [AS_HELP_STRING([--enable-werror],
|
||||
+ [turn GCC warnings into errors (for developers)])],
|
||||
+ [case $enableval in
|
||||
+ yes|no) ;;
|
||||
+ *) AC_MSG_ERROR([bad value $enableval for werror option]) ;;
|
||||
+ esac
|
||||
+ gcc_werror=$enableval],
|
||||
+ [gcc_werror=no]
|
||||
+)
|
||||
+if test "$gcc_werror" = "yes"; then
|
||||
+ gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
||||
+ AC_SUBST([WERROR_CFLAGS])
|
||||
+fi
|
||||
+
|
||||
+# $nw is the list of warnings we want to *disable*. The nw warnings
|
||||
+# are complemented below.
|
||||
+nw=
|
||||
+nw="$nw -Wvla" # Allow variable length arrays.
|
||||
+nw="$nw -Wsuggest-attribute=pure" # Don't suggest function attributes.
|
||||
+nw="$nw -Wsuggest-attribute=const"
|
||||
+nw="$nw -Wsuggest-attribute=format"
|
||||
+nw="$nw -Wstrict-prototypes" # Don't require prototypes for every function.
|
||||
+nw="$nw -Wmissing-prototypes"
|
||||
+nw="$nw -Wmissing-declarations"
|
||||
+nw="$nw -Wpacked" # Don't warn about packed structs.
|
||||
+nw="$nw -Wswitch-default" # This warning is actively dangerous.
|
||||
+nw="$nw -Wunused-macros" # Don't warn about defined but unused macros.
|
||||
+
|
||||
+gl_MANYWARN_ALL_GCC([ws])
|
||||
+gl_MANYWARN_COMPLEMENT([ws], [$ws], $[nw])
|
||||
+for w in $ws; do
|
||||
+ gl_WARN_ADD([$w])
|
||||
+done
|
||||
+
|
||||
+# Normally we disable warnings in $nw above. However $nw only
|
||||
+# filters out exact matching warning strings from a list inside
|
||||
+# gnulib (see m4/manywarnings.m4). So we need to explicitly list a
|
||||
+# few disabled warnings below.
|
||||
+
|
||||
+# Allow unused function parameters.
|
||||
+gl_WARN_ADD([-Wno-unused-parameter])
|
||||
+
|
||||
+AC_SUBST([WARN_CFLAGS])
|
||||
+
|
||||
# Gettext
|
||||
AM_GNU_GETTEXT([external])
|
||||
# AM_GNU_GETTEXT_VERSION(0.14.1)
|
||||
diff --git a/icotool/Makefile.am b/icotool/Makefile.am
|
||||
index bd27fc8..8c42c9e 100644
|
||||
--- a/icotool/Makefile.am
|
||||
+++ b/icotool/Makefile.am
|
||||
@@ -28,4 +28,4 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/lib \
|
||||
-I$(top_srcdir)
|
||||
|
||||
-AM_CFLAGS = -Wall
|
||||
+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||
diff --git a/wrestool/Makefile.am b/wrestool/Makefile.am
|
||||
index e18b9c2..3b5f3d4 100644
|
||||
--- a/wrestool/Makefile.am
|
||||
+++ b/wrestool/Makefile.am
|
||||
@@ -27,4 +27,4 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(srcdir)/../icotool
|
||||
|
||||
-AM_CFLAGS = -Wall
|
||||
+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,80 +0,0 @@
|
||||
From a62bcad4953223057c37a00d3bcdb051f2283578 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 13:07:11 +0000
|
||||
Subject: [PATCH 07/26] common/intutil.c: Avoid comparison between signed and
|
||||
unsigned.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
By using an unsigned char to hold the character we can avoid needing
|
||||
to check for c < 0 and also avoid the comparison between signed and
|
||||
unsigned integers.
|
||||
|
||||
In GCC the warning/error was:
|
||||
|
||||
intutil.c: In function ‘parse_uint32’:
|
||||
intutil.c:249:63: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
|
||||
if (value > UINT32_MAX/10L || (value == UINT32_MAX/10L && c > UINT32_MAX%10))
|
||||
^
|
||||
intutil.c: In function ‘parse_uint64’:
|
||||
intutil.c:267:65: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
|
||||
if (value > UINT64_MAX/10LL || (value == UINT64_MAX/10LL && c > UINT64_MAX%10LL))
|
||||
^
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
common/intutil.c | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/common/intutil.c b/common/intutil.c
|
||||
index 57f8cb1..d500ba7 100644
|
||||
--- a/common/intutil.c
|
||||
+++ b/common/intutil.c
|
||||
@@ -207,8 +207,8 @@ parse_uint8(const char *instr, uint8_t *outint)
|
||||
uint8_t value = 0;
|
||||
|
||||
for (; *instr != '\0'; instr++) {
|
||||
- int8_t c = *instr - '0';
|
||||
- if (c < 0 || c > 9)
|
||||
+ uint8_t c = *instr - '0';
|
||||
+ if (c > 9)
|
||||
return false;
|
||||
if (value > UINT8_MAX/10 || (value == UINT8_MAX/10 && c > UINT8_MAX%10))
|
||||
return false;
|
||||
@@ -225,8 +225,8 @@ parse_uint16(const char *instr, uint16_t *outint)
|
||||
uint16_t value = 0;
|
||||
|
||||
for (; *instr != '\0'; instr++) {
|
||||
- int8_t c = *instr - '0';
|
||||
- if (c < 0 || c > 9)
|
||||
+ uint8_t c = *instr - '0';
|
||||
+ if (c > 9)
|
||||
return false;
|
||||
if (value > UINT16_MAX/10 || (value == UINT16_MAX/10 && c > UINT16_MAX%10))
|
||||
return false;
|
||||
@@ -243,8 +243,8 @@ parse_uint32(const char *instr, uint32_t *outint)
|
||||
uint32_t value = 0;
|
||||
|
||||
for (; *instr != '\0'; instr++) {
|
||||
- int8_t c = *instr - '0';
|
||||
- if (c < 0 || c > 9)
|
||||
+ uint8_t c = *instr - '0';
|
||||
+ if (c > 9)
|
||||
return false;
|
||||
if (value > UINT32_MAX/10L || (value == UINT32_MAX/10L && c > UINT32_MAX%10))
|
||||
return false;
|
||||
@@ -261,8 +261,8 @@ parse_uint64(const char *instr, uint64_t *outint)
|
||||
uint64_t value = 0;
|
||||
|
||||
for (; *instr != '\0'; instr++) {
|
||||
- int8_t c = *instr - '0';
|
||||
- if (c < 0 || c > 9)
|
||||
+ uint8_t c = *instr - '0';
|
||||
+ if (c > 9)
|
||||
return false;
|
||||
if (value > UINT64_MAX/10LL || (value == UINT64_MAX/10LL && c > UINT64_MAX%10LL))
|
||||
return false;
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,79 +0,0 @@
|
||||
From 2d6c1451631989d6eda202a0e996c4e39ab788fc Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 13:10:34 +0000
|
||||
Subject: [PATCH 08/26] common/llist.c: Avoid unnecessary comparisons unsigned
|
||||
< 0.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Unsigned is always zero or positive, so there is no need to compare
|
||||
with < 0.
|
||||
|
||||
The original warnings/errors from GCC were:
|
||||
|
||||
llist.c: In function ‘llist_get’:
|
||||
llist.c:284:12: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
|
||||
if (index < 0 || index >= list->size)
|
||||
^
|
||||
llist.c: In function ‘llist_set’:
|
||||
llist.c:297:12: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
|
||||
if (index < 0 || index >= list->size)
|
||||
^
|
||||
llist.c: In function ‘llist_add_at’:
|
||||
llist.c:319:12: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
|
||||
if (index < 0 || index > list->size)
|
||||
^
|
||||
llist.c: In function ‘llist_remove_at’:
|
||||
llist.c:346:12: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
|
||||
if (index < 0 || index >= list->size)
|
||||
^
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
common/llist.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/common/llist.c b/common/llist.c
|
||||
index 01a74de..873f36c 100644
|
||||
--- a/common/llist.c
|
||||
+++ b/common/llist.c
|
||||
@@ -281,7 +281,7 @@ llist_get(LList *list, uint32_t index)
|
||||
{
|
||||
LNode *entry;
|
||||
|
||||
- if (index < 0 || index >= list->size)
|
||||
+ if (index >= list->size)
|
||||
return NULL;
|
||||
|
||||
entry = llist_get_entry(list, index);
|
||||
@@ -294,7 +294,7 @@ llist_set(LList *list, uint32_t index, void *data)
|
||||
LNode *entry;
|
||||
void *old_data;
|
||||
|
||||
- if (index < 0 || index >= list->size)
|
||||
+ if (index >= list->size)
|
||||
return NULL;
|
||||
|
||||
entry = llist_get_entry(list, index);
|
||||
@@ -316,7 +316,7 @@ llist_add_at(LList *list, uint32_t index, void *data)
|
||||
{
|
||||
LNode *entry;
|
||||
|
||||
- if (index < 0 || index > list->size)
|
||||
+ if (index > list->size)
|
||||
return;
|
||||
|
||||
entry = xmalloc(sizeof(LNode));
|
||||
@@ -343,7 +343,7 @@ llist_remove_at(LList *list, uint32_t index)
|
||||
LNode *entry;
|
||||
void *data;
|
||||
|
||||
- if (index < 0 || index >= list->size)
|
||||
+ if (index >= list->size)
|
||||
return NULL;
|
||||
|
||||
entry = llist_get_entry(list, index);
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,411 +0,0 @@
|
||||
From edb7fc727a29f4ae8dcd6fee02fb5c08286808c5 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 13:25:33 +0000
|
||||
Subject: [PATCH 09/26] common/strbuf.c: Use size_t and ssize_t.
|
||||
|
||||
On 64 bit machines, strings can be longer than 2^32 characters.
|
||||
size_t or ssize_t should be used to handle all offsets and lengths of
|
||||
such strings to avoid overflow.
|
||||
|
||||
This makes the fairly mechanical change int32_t -> ssize_t and
|
||||
uint32_t -> size_t.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
common/strbuf.c | 80 ++++++++++++++++++++++++++++-----------------------------
|
||||
common/strbuf.h | 50 ++++++++++++++++++------------------
|
||||
2 files changed, 65 insertions(+), 65 deletions(-)
|
||||
|
||||
diff --git a/common/strbuf.c b/common/strbuf.c
|
||||
index 5c42873..cf90d5a 100644
|
||||
--- a/common/strbuf.c
|
||||
+++ b/common/strbuf.c
|
||||
@@ -36,12 +36,12 @@
|
||||
|
||||
#define DEFAULT_STRBUF_CAPACITY 16
|
||||
|
||||
-#define SWAP_INT32(a,b) { int32_t _t = (a); (a) = (b); (b) = _t; }
|
||||
+#define SWAP_SSIZE_T(a,b) { ssize_t _t = (a); (a) = (b); (b) = _t; }
|
||||
|
||||
-static int32_t
|
||||
-normalize_strbuf_pos(StrBuf *sb, int32_t pos)
|
||||
+static ssize_t
|
||||
+normalize_strbuf_pos(StrBuf *sb, ssize_t pos)
|
||||
{
|
||||
- if (pos >= sb->len)
|
||||
+ if (pos >= (ssize_t) sb->len)
|
||||
return sb->len;
|
||||
if (pos >= 0)
|
||||
return pos;
|
||||
@@ -51,8 +51,8 @@ normalize_strbuf_pos(StrBuf *sb, int32_t pos)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int32_t
|
||||
-normalize_str_pos(const char *str, int32_t pos)
|
||||
+static ssize_t
|
||||
+normalize_str_pos(const char *str, ssize_t pos)
|
||||
{
|
||||
if (str == NULL)
|
||||
return 0;
|
||||
@@ -70,13 +70,13 @@ strbuf_buffer(StrBuf *sb)
|
||||
return sb->buf;
|
||||
}
|
||||
|
||||
-uint32_t
|
||||
+size_t
|
||||
strbuf_length(StrBuf *sb)
|
||||
{
|
||||
return sb->len;
|
||||
}
|
||||
|
||||
-uint32_t
|
||||
+size_t
|
||||
strbuf_capacity(StrBuf *sb)
|
||||
{
|
||||
return sb->capacity;
|
||||
@@ -89,7 +89,7 @@ strbuf_new(void)
|
||||
}
|
||||
|
||||
StrBuf *
|
||||
-strbuf_new_with_capacity(uint32_t capacity)
|
||||
+strbuf_new_with_capacity(size_t capacity)
|
||||
{
|
||||
StrBuf *sb;
|
||||
sb = xmalloc(sizeof(StrBuf));
|
||||
@@ -102,24 +102,24 @@ strbuf_new_with_capacity(uint32_t capacity)
|
||||
}
|
||||
|
||||
StrBuf *
|
||||
-strbuf_new_from_char_n(uint32_t times, char ch)
|
||||
+strbuf_new_from_char_n(size_t times, char ch)
|
||||
{
|
||||
return strbuf_new_from_substring_n(times, &ch, 0, 1);
|
||||
}
|
||||
|
||||
StrBuf *
|
||||
-strbuf_new_from_substring_n(uint32_t times, const char *substr, int32_t subsp, int32_t subep)
|
||||
+strbuf_new_from_substring_n(size_t times, const char *substr, ssize_t subsp, ssize_t subep)
|
||||
{
|
||||
subsp = normalize_str_pos(substr, subsp);
|
||||
subep = normalize_str_pos(substr, subep);
|
||||
if (subsp > subep)
|
||||
- SWAP_INT32(subsp, subep);
|
||||
+ SWAP_SSIZE_T(subsp, subep);
|
||||
|
||||
return strbuf_new_from_data_n(times, substr+subsp, subep-subsp);
|
||||
}
|
||||
|
||||
StrBuf *
|
||||
-strbuf_new_from_data_n(uint32_t times, const void *mem, uint32_t len)
|
||||
+strbuf_new_from_data_n(size_t times, const void *mem, size_t len)
|
||||
{
|
||||
StrBuf *sb;
|
||||
|
||||
@@ -133,7 +133,7 @@ strbuf_new_from_data_n(uint32_t times, const void *mem, uint32_t len)
|
||||
}
|
||||
|
||||
StrBuf *
|
||||
-strbuf_newf_n(uint32_t times, const char *fmt, ...)
|
||||
+strbuf_newf_n(size_t times, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
StrBuf *buf;
|
||||
@@ -146,7 +146,7 @@ strbuf_newf_n(uint32_t times, const char *fmt, ...)
|
||||
}
|
||||
|
||||
StrBuf *
|
||||
-strbuf_vnewf_n(uint32_t times, const char *fmt, va_list ap)
|
||||
+strbuf_vnewf_n(size_t times, const char *fmt, va_list ap)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
@@ -171,7 +171,7 @@ strbuf_free(StrBuf *sb)
|
||||
}
|
||||
|
||||
char *
|
||||
-strbuf_free_to_substring(StrBuf *sb, int32_t sp, int32_t ep)
|
||||
+strbuf_free_to_substring(StrBuf *sb, ssize_t sp, ssize_t ep)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
@@ -182,7 +182,7 @@ strbuf_free_to_substring(StrBuf *sb, int32_t sp, int32_t ep)
|
||||
sb->buf[ep-sp] = '\0';
|
||||
|
||||
/* Call realloc so that unused memory can be used for other purpose. */
|
||||
- if (sp == 0 && ep == sb->len)
|
||||
+ if (sp == 0 && ep == (ssize_t) sb->len)
|
||||
buf = sb->buf;
|
||||
else
|
||||
buf = xrealloc(sb->buf, ep-sp+1);
|
||||
@@ -191,21 +191,21 @@ strbuf_free_to_substring(StrBuf *sb, int32_t sp, int32_t ep)
|
||||
}
|
||||
|
||||
void
|
||||
-strbuf_replace_char_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, char ch)
|
||||
+strbuf_replace_char_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, char ch)
|
||||
{
|
||||
strbuf_replace_substring_n(sb, sp, ep, times, &ch, 0, 1);
|
||||
}
|
||||
|
||||
void
|
||||
-strbuf_replace_data_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const void *mem, uint32_t len)
|
||||
+strbuf_replace_data_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, const void *mem, size_t len)
|
||||
{
|
||||
- uint32_t addlen;
|
||||
- uint32_t dellen;
|
||||
+ size_t addlen;
|
||||
+ size_t dellen;
|
||||
|
||||
sp = normalize_strbuf_pos(sb, sp);
|
||||
ep = normalize_strbuf_pos(sb, ep);
|
||||
if (sp > ep)
|
||||
- SWAP_INT32(sp, ep);
|
||||
+ SWAP_SSIZE_T(sp, ep);
|
||||
|
||||
addlen = len * times;
|
||||
dellen = ep-sp;
|
||||
@@ -223,18 +223,18 @@ strbuf_replace_data_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const
|
||||
}
|
||||
|
||||
void
|
||||
-strbuf_replace_substring_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const char *substr, int32_t subsp, int32_t subep)
|
||||
+strbuf_replace_substring_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, const char *substr, ssize_t subsp, ssize_t subep)
|
||||
{
|
||||
subsp = normalize_str_pos(substr, subsp);
|
||||
subep = normalize_str_pos(substr, subep);
|
||||
if (subsp > subep)
|
||||
- SWAP_INT32(subsp, subep);
|
||||
+ SWAP_SSIZE_T(subsp, subep);
|
||||
|
||||
strbuf_replace_data_n(sb, sp, ep, times, substr+subsp, subep-subsp);
|
||||
}
|
||||
|
||||
int
|
||||
-strbuf_replacef_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const char *fmt, ...)
|
||||
+strbuf_replacef_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int len;
|
||||
@@ -247,7 +247,7 @@ strbuf_replacef_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const char
|
||||
}
|
||||
|
||||
int
|
||||
-strbuf_vreplacef_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const char *fmt, va_list ap)
|
||||
+strbuf_vreplacef_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, const char *fmt, va_list ap)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
@@ -255,7 +255,7 @@ strbuf_vreplacef_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const cha
|
||||
sp = normalize_strbuf_pos(sb, sp);
|
||||
ep = normalize_strbuf_pos(sb, ep);
|
||||
if (sp > ep)
|
||||
- SWAP_INT32(sp, ep);
|
||||
+ SWAP_SSIZE_T(sp, ep);
|
||||
|
||||
len = vasprintf(&str, fmt, ap);
|
||||
if (len < 0)
|
||||
@@ -267,29 +267,29 @@ strbuf_vreplacef_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const cha
|
||||
}
|
||||
|
||||
void
|
||||
-strbuf_reverse_substring(StrBuf *sb, int32_t sp, int32_t ep)
|
||||
+strbuf_reverse_substring(StrBuf *sb, ssize_t sp, ssize_t ep)
|
||||
{
|
||||
sp = normalize_strbuf_pos(sb, sp);
|
||||
ep = normalize_strbuf_pos(sb, ep);
|
||||
|
||||
while (sp < ep) {
|
||||
- SWAP_INT32(sb->buf[sp], sb->buf[ep]);
|
||||
+ SWAP_SSIZE_T(sb->buf[sp], sb->buf[ep]);
|
||||
sp++;
|
||||
ep--;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
-strbuf_repeat_substring(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times)
|
||||
+strbuf_repeat_substring(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times)
|
||||
{
|
||||
- int32_t addlen;
|
||||
+ ssize_t addlen;
|
||||
|
||||
sp = normalize_strbuf_pos(sb, sp);
|
||||
ep = normalize_strbuf_pos(sb, ep);
|
||||
|
||||
addlen = (ep-sp) * (times - 1);
|
||||
if (addlen != 0) {
|
||||
- uint32_t p;
|
||||
+ size_t p;
|
||||
|
||||
strbuf_ensure_capacity(sb, sb->len+1+addlen);
|
||||
memmove(sb->buf+sp+addlen, sb->buf+ep, sb->len+1-ep);
|
||||
@@ -304,7 +304,7 @@ strbuf_repeat_substring(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times)
|
||||
}
|
||||
|
||||
void
|
||||
-strbuf_set_length(StrBuf *sb, uint32_t new_length)
|
||||
+strbuf_set_length(StrBuf *sb, size_t new_length)
|
||||
{
|
||||
strbuf_ensure_capacity(sb, new_length+1);
|
||||
sb->buf[new_length] = '\0';
|
||||
@@ -313,7 +313,7 @@ strbuf_set_length(StrBuf *sb, uint32_t new_length)
|
||||
|
||||
/* Note: The terminating null-byte counts as 1 in min_capacity */
|
||||
void
|
||||
-strbuf_ensure_capacity(StrBuf *sb, uint32_t min_capacity)
|
||||
+strbuf_ensure_capacity(StrBuf *sb, size_t min_capacity)
|
||||
{
|
||||
if (min_capacity > sb->capacity) {
|
||||
sb->capacity = MAX(min_capacity, sb->len*2+2); /* MAX -> max */
|
||||
@@ -324,14 +324,14 @@ strbuf_ensure_capacity(StrBuf *sb, uint32_t min_capacity)
|
||||
}
|
||||
|
||||
char *
|
||||
-strbuf_substring(StrBuf *sb, int32_t sp, int32_t ep)
|
||||
+strbuf_substring(StrBuf *sb, ssize_t sp, ssize_t ep)
|
||||
{
|
||||
char *str;
|
||||
|
||||
sp = normalize_strbuf_pos(sb, sp);
|
||||
ep = normalize_strbuf_pos(sb, ep);
|
||||
if (sp > ep)
|
||||
- SWAP_INT32(sp, ep);
|
||||
+ SWAP_SSIZE_T(sp, ep);
|
||||
|
||||
str = xmalloc((ep-sp+1) * sizeof(char));
|
||||
memcpy(str, sb->buf+sp, (ep-sp+1) * sizeof(char));
|
||||
@@ -341,14 +341,14 @@ strbuf_substring(StrBuf *sb, int32_t sp, int32_t ep)
|
||||
}
|
||||
|
||||
char
|
||||
-strbuf_char_at(StrBuf *sb, int32_t sp)
|
||||
+strbuf_char_at(StrBuf *sb, ssize_t sp)
|
||||
{
|
||||
return sb->buf[normalize_strbuf_pos(sb, sp)];
|
||||
}
|
||||
|
||||
#if 0
|
||||
char
|
||||
-strbuf_set_char_at(StrBuf *sb, int32_t sp, char chr)
|
||||
+strbuf_set_char_at(StrBuf *sb, ssize_t sp, char chr)
|
||||
{
|
||||
char old;
|
||||
|
||||
@@ -364,13 +364,13 @@ strbuf_set_char_at(StrBuf *sb, int32_t sp, char chr)
|
||||
}
|
||||
|
||||
void
|
||||
-strbuf_replace_strbuf(StrBuf *sb, int32_t sp, int32_t ep, StrBuf *strbuf)
|
||||
+strbuf_replace_strbuf(StrBuf *sb, ssize_t sp, ssize_t ep, StrBuf *strbuf)
|
||||
{
|
||||
strbuf_replace_data_n(sb,sp,ep,1,strbuf->buf,strbuf->len);
|
||||
}
|
||||
|
||||
char
|
||||
-strbuf_delete_char(StrBuf *sb, int32_t sp)
|
||||
+strbuf_delete_char(StrBuf *sb, ssize_t sp)
|
||||
{
|
||||
|
||||
}
|
||||
diff --git a/common/strbuf.h b/common/strbuf.h
|
||||
index 67a523d..6cd0d58 100644
|
||||
--- a/common/strbuf.h
|
||||
+++ b/common/strbuf.h
|
||||
@@ -28,16 +28,16 @@ typedef struct _StrBuf StrBuf;
|
||||
|
||||
struct _StrBuf {
|
||||
char *buf;
|
||||
- uint32_t len;
|
||||
- uint32_t capacity;
|
||||
+ size_t len;
|
||||
+ size_t capacity;
|
||||
};
|
||||
|
||||
void strbuf_free(StrBuf *sb);
|
||||
#define strbuf_free_to_string(sb) strbuf_free_to_substring(sb,0,-1)
|
||||
-char *strbuf_free_to_substring(StrBuf *sb, int32_t sp, int32_t ep);
|
||||
+char *strbuf_free_to_substring(StrBuf *sb, ssize_t sp, ssize_t ep);
|
||||
|
||||
StrBuf *strbuf_new(void);
|
||||
-StrBuf *strbuf_new_with_capacity(uint32_t capacity);
|
||||
+StrBuf *strbuf_new_with_capacity(size_t capacity);
|
||||
|
||||
#define strbuf_new_from_char(chr) strbuf_new_from_char_n(1,chr)
|
||||
#define strbuf_new_from_string(str) strbuf_new_from_substring(str,0,-1)
|
||||
@@ -46,12 +46,12 @@ StrBuf *strbuf_new_with_capacity(uint32_t capacity);
|
||||
#define strbuf_new_from_substring(str,ssp,sep) strbuf_new_from_substring_n(1,str,ssp,sep)
|
||||
#define strbuf_newf(fmt...) strbuf_newf_n(1,fmt)
|
||||
#define strbuf_vnewf(fmt,ap) strbuf_vnewf_n(1,fmt,ap)
|
||||
-StrBuf *strbuf_new_from_char_n(uint32_t times, char ch);
|
||||
+StrBuf *strbuf_new_from_char_n(size_t times, char ch);
|
||||
#define strbuf_new_from_string_n(n,str) strbuf_new_from_substring_n(n,str,0,-1)
|
||||
-StrBuf *strbuf_new_from_substring_n(uint32_t times, const char *str, int32_t sp, int32_t ep);
|
||||
-StrBuf *strbuf_new_from_data_n(uint32_t times, const void *mem, uint32_t len);
|
||||
-StrBuf *strbuf_newf_n(uint32_t times, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
-StrBuf *strbuf_vnewf_n(uint32_t times, const char *fmt, va_list ap) __attribute__ ((format (printf, 2, 0)));
|
||||
+StrBuf *strbuf_new_from_substring_n(size_t times, const char *str, ssize_t sp, ssize_t ep);
|
||||
+StrBuf *strbuf_new_from_data_n(size_t times, const void *mem, size_t len);
|
||||
+StrBuf *strbuf_newf_n(size_t times, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
+StrBuf *strbuf_vnewf_n(size_t times, const char *fmt, va_list ap) __attribute__ ((format (printf, 2, 0)));
|
||||
|
||||
#define strbuf_append_char(sb,chr) strbuf_append_char_n(sb,1,chr)
|
||||
#define strbuf_append(sb,str) strbuf_append_n(sb,1,str)
|
||||
@@ -116,38 +116,38 @@ StrBuf *strbuf_vnewf_n(uint32_t times, const char *fmt, va_list ap) __attribute_
|
||||
#define strbuf_replace_char(sb,sp,ep,ch) strbuf_replace_char_n(sb,sp,ep,1,ch)
|
||||
#define strbuf_replace(sb,sp,ep,str) strbuf_replace_n(sb,sp,ep,1,str)
|
||||
#define strbuf_replace_data(sb,sp,ep,mem,len) strbuf_replace_data_n(sb,sp,ep,1,mem,len)
|
||||
-void strbuf_replace_strbuf(StrBuf *sb, int32_t sp, int32_t ep, StrBuf *strbuf); /* or strbuf_replace_data_n(sb,sp,ep,1,strbuf_buffer(strbuf),strbuf_length(strbuf))*/
|
||||
+void strbuf_replace_strbuf(StrBuf *sb, ssize_t sp, ssize_t ep, StrBuf *strbuf); /* or strbuf_replace_data_n(sb,sp,ep,1,strbuf_buffer(strbuf),strbuf_length(strbuf))*/
|
||||
#define strbuf_replace_substring(sb,sp,ep,str,ssp,sep) strbuf_replace_substring_n(sb,sp,ep,1,str,ssp,sep)
|
||||
#define strbuf_replacef(sb,sp,ep,fmt...) strbuf_replacef_n(sb,sp,ep,1,fmt)
|
||||
#define strbuf_vreplacef(sb,sp,ep,fmt,ap) strbuf_vreplacef_n(sb,sp,ep,1,fmt,ap)
|
||||
-void strbuf_replace_char_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, char ch);
|
||||
+void strbuf_replace_char_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, char ch);
|
||||
#define strbuf_replace_n(sb,sp,ep,n,str) strbuf_replace_substring_n(sb,sp,ep,n,str,0,-1)
|
||||
-void strbuf_replace_substring_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const char *str, int32_t ssp, int32_t sep);
|
||||
-void strbuf_replace_data_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const void *mem, uint32_t len);
|
||||
-int strbuf_replacef_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const char *fmt, ...) __attribute__ ((format (printf, 5, 6)));
|
||||
-int strbuf_vreplacef_n(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times, const char *fmt, va_list ap) __attribute__ ((format (printf, 5, 0)));
|
||||
+void strbuf_replace_substring_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, const char *str, ssize_t ssp, ssize_t sep);
|
||||
+void strbuf_replace_data_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, const void *mem, size_t len);
|
||||
+int strbuf_replacef_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, const char *fmt, ...) __attribute__ ((format (printf, 5, 6)));
|
||||
+int strbuf_vreplacef_n(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times, const char *fmt, va_list ap) __attribute__ ((format (printf, 5, 0)));
|
||||
|
||||
-char strbuf_set_char_at(StrBuf *sb, int32_t sp, char chr); /* or strbuf_replace_char(sb,sp,strbuf_next_pos(sb,sp),chr) */
|
||||
-char strbuf_delete_char(StrBuf *sb, int32_t sp); /* or strbuf_replace(sb,sp,strbuf_next_pos(sb,sp),NULL) */
|
||||
+char strbuf_set_char_at(StrBuf *sb, ssize_t sp, char chr); /* or strbuf_replace_char(sb,sp,strbuf_next_pos(sb,sp),chr) */
|
||||
+char strbuf_delete_char(StrBuf *sb, ssize_t sp); /* or strbuf_replace(sb,sp,strbuf_next_pos(sb,sp),NULL) */
|
||||
#define strbuf_delete(sb,sp,ep) strbuf_replace(sb,sp,ep,NULL)
|
||||
#define strbuf_clear(sb) strbuf_replace(sb,0,-1,NULL)
|
||||
|
||||
-void strbuf_reverse_substring(StrBuf *sb, int32_t sp, int32_t ep);
|
||||
+void strbuf_reverse_substring(StrBuf *sb, ssize_t sp, ssize_t ep);
|
||||
#define strbuf_reverse(sb) strbuf_reverse_substring(sb,0,-1)
|
||||
|
||||
-void strbuf_repeat_substring(StrBuf *sb, int32_t sp, int32_t ep, uint32_t times);
|
||||
+void strbuf_repeat_substring(StrBuf *sb, ssize_t sp, ssize_t ep, size_t times);
|
||||
#define strbuf_repeat(sb,n) strbuf_repeat_substring(sb,0,-1,n)
|
||||
|
||||
-uint32_t strbuf_length(StrBuf *sb);
|
||||
-uint32_t strbuf_capacity(StrBuf *sb);
|
||||
+size_t strbuf_length(StrBuf *sb);
|
||||
+size_t strbuf_capacity(StrBuf *sb);
|
||||
char *strbuf_buffer(StrBuf *sb);
|
||||
#define strbuf_is_empty(sb) (strbuf_length(sb) == 0)
|
||||
|
||||
-void strbuf_set_length(StrBuf *sb, uint32_t new_length);
|
||||
-void strbuf_ensure_capacity(StrBuf *sb, uint32_t minimum_capacity); /* minimum_capacity should account for null-byte */
|
||||
+void strbuf_set_length(StrBuf *sb, size_t new_length);
|
||||
+void strbuf_ensure_capacity(StrBuf *sb, size_t minimum_capacity); /* minimum_capacity should account for null-byte */
|
||||
|
||||
-char *strbuf_substring(StrBuf *sb, int32_t sp, int32_t ep);
|
||||
+char *strbuf_substring(StrBuf *sb, ssize_t sp, ssize_t ep);
|
||||
#define strbuf_to_string(sb) strbuf_substring(sb,0,-1)
|
||||
-char strbuf_char_at(StrBuf *sb, int32_t index);
|
||||
+char strbuf_char_at(StrBuf *sb, ssize_t index);
|
||||
|
||||
#endif
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,48 +0,0 @@
|
||||
From 657025565cbd4640fd7f85a2e55ce470e1da748a Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 13:29:37 +0000
|
||||
Subject: [PATCH 10/26] common/tmap.c: Safe comparison of two pointers.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Subtracting two pointers and assigning the result to a 32 bit integer
|
||||
is never safe on 64 bit architectures -- ptrdiff_t should be used in
|
||||
this situation. Also subtracting void pointers is undefined in C.
|
||||
|
||||
Since we require an 'int' result, the easiest fix is to open code the
|
||||
comparison we require. GCC optimizes this function to six instructions.
|
||||
|
||||
The original warning was:
|
||||
|
||||
tmap.c: In function ‘ptrcmp’:
|
||||
tmap.c:67:21: error: pointer of type ‘void *’ used in subtraction [-Werror=pointer-arith]
|
||||
return (int) (v0-v1);
|
||||
^
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
common/tmap.c | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/common/tmap.c b/common/tmap.c
|
||||
index afa2203..bdbd0e3 100644
|
||||
--- a/common/tmap.c
|
||||
+++ b/common/tmap.c
|
||||
@@ -64,7 +64,12 @@ static TMapNode nil = { NULL, NULL, false, &nil, &nil, &nil };
|
||||
static int
|
||||
ptrcmp(const void *v0, const void *v1)
|
||||
{
|
||||
- return (int) (v0-v1);
|
||||
+ if (v0 == v1)
|
||||
+ return 0;
|
||||
+ else if (v0 < v1)
|
||||
+ return -1;
|
||||
+ else
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,72 +0,0 @@
|
||||
From 8c5b54454f816e26c52a18870f4ddb3789103313 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 13:49:56 +0000
|
||||
Subject: [PATCH 11/26] icotool: Use size_t when counting array elements, not
|
||||
int.
|
||||
|
||||
It's not safe to use int when counting array elements, as on 64 bit
|
||||
platforms the arrays can overflow a 32 bit int. (That is, in general.
|
||||
In this particular case it probably is safe because the original array
|
||||
is derived from argv. But it's easier to use the correct type.)
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
icotool/create.c | 7 ++++---
|
||||
icotool/icotool.h | 2 +-
|
||||
icotool/main.c | 2 +-
|
||||
3 files changed, 6 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/icotool/create.c b/icotool/create.c
|
||||
index 2e2ccbf..20a0630 100644
|
||||
--- a/icotool/create.c
|
||||
+++ b/icotool/create.c
|
||||
@@ -66,7 +66,7 @@ xfread(void *ptr, size_t size, FILE *stream)
|
||||
}
|
||||
|
||||
bool
|
||||
-create_icon(int filec, char **filev, int raw_filec, char** raw_filev, CreateNameGen outfile_gen, bool icon_mode, int32_t hotspot_x, int32_t hotspot_y, int32_t alpha_threshold, int32_t bit_count)
|
||||
+create_icon(size_t filec, char **filev, size_t raw_filec, char** raw_filev, CreateNameGen outfile_gen, bool icon_mode, int32_t hotspot_x, int32_t hotspot_y, int32_t alpha_threshold, int32_t bit_count)
|
||||
{
|
||||
struct {
|
||||
FILE *in;
|
||||
@@ -87,10 +87,11 @@ create_icon(int filec, char **filev, int raw_filec, char** raw_filev, CreateName
|
||||
Win32CursorIconFileDir dir;
|
||||
FILE *out;
|
||||
char *outname = NULL;
|
||||
- uint32_t c, d, x;
|
||||
+ size_t c;
|
||||
+ uint32_t d, x;
|
||||
uint32_t dib_start;
|
||||
png_byte ct;
|
||||
- int org_filec = filec;
|
||||
+ size_t org_filec = filec;
|
||||
|
||||
filec += raw_filec;
|
||||
|
||||
diff --git a/icotool/icotool.h b/icotool/icotool.h
|
||||
index ce3bec2..ba2fbbd 100644
|
||||
--- a/icotool/icotool.h
|
||||
+++ b/icotool/icotool.h
|
||||
@@ -42,5 +42,5 @@ int extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_
|
||||
|
||||
/* create.c */
|
||||
typedef FILE *(*CreateNameGen)(char **outname);
|
||||
-bool create_icon(int filec, char **filev, int raw_filec, char** raw_filev, CreateNameGen outfile_gen, bool icon_mode, int32_t hotspot_x, int32_t hotspot_y, int32_t alpha_threshold, int32_t bit_count);
|
||||
+bool create_icon(size_t filec, char **filev, size_t raw_filec, char** raw_filev, CreateNameGen outfile_gen, bool icon_mode, int32_t hotspot_x, int32_t hotspot_y, int32_t alpha_threshold, int32_t bit_count);
|
||||
#endif
|
||||
diff --git a/icotool/main.c b/icotool/main.c
|
||||
index 916fd7f..ec63017 100644
|
||||
--- a/icotool/main.c
|
||||
+++ b/icotool/main.c
|
||||
@@ -217,7 +217,7 @@ main(int argc, char **argv)
|
||||
bool create_mode = false;
|
||||
FILE *in;
|
||||
char *inname;
|
||||
- int raw_filec = 0;
|
||||
+ size_t raw_filec = 0;
|
||||
char** raw_filev = 0;
|
||||
|
||||
set_program_name(argv[0]);
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,77 +0,0 @@
|
||||
From 7d8a205535a4368a0b24358e122767153d0e1fdf Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 13:52:08 +0000
|
||||
Subject: [PATCH 12/26] icotool: Fix some comparisons of signed/unsigned.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
icotool/create.c | 8 ++++----
|
||||
icotool/extract.c | 6 +++---
|
||||
2 files changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/icotool/create.c b/icotool/create.c
|
||||
index 20a0630..0e922e0 100644
|
||||
--- a/icotool/create.c
|
||||
+++ b/icotool/create.c
|
||||
@@ -222,7 +222,7 @@ create_icon(size_t filec, char **filev, size_t raw_filec, char** raw_filev, Crea
|
||||
img[c].palette_count = 0;
|
||||
}
|
||||
else if (palette_count(img[c].palette) <= 256) {
|
||||
- for (d = 1; palette_count(img[c].palette) > 1 << d; d <<= 1);
|
||||
+ for (d = 1; palette_count(img[c].palette) > (uint32_t)(1 << d); d <<= 1);
|
||||
if (d == 2) /* four colors (two bits) are not supported */
|
||||
d = 4;
|
||||
img[c].bit_count = d;
|
||||
@@ -235,9 +235,9 @@ create_icon(size_t filec, char **filev, size_t raw_filec, char** raw_filev, Crea
|
||||
|
||||
/* Does the user want to change number of bits per pixel? */
|
||||
if (bit_count != -1) {
|
||||
- if (img[c].bit_count == bit_count) {
|
||||
+ if (img[c].bit_count == (uint32_t) bit_count) {
|
||||
/* No operation */
|
||||
- } else if (img[c].bit_count < bit_count) {
|
||||
+ } else if (img[c].bit_count < (uint32_t) bit_count) {
|
||||
img[c].bit_count = bit_count;
|
||||
img[c].palette_count = (bit_count > 16 ? 0 : 1 << bit_count);
|
||||
} else {
|
||||
@@ -357,7 +357,7 @@ create_icon(size_t filec, char **filev, size_t raw_filec, char** raw_filev, Crea
|
||||
* programs that read icons assume it. Especially gdk-pixbuf.
|
||||
*/
|
||||
memset(&color, 0, sizeof(Win32RGBQuad));
|
||||
- for (d = palette_count(img[c].palette); d < 1 << img[c].bit_count; d++)
|
||||
+ for (d = palette_count(img[c].palette); d < (uint32_t) (1 << img[c].bit_count); d++)
|
||||
fwrite(&color, sizeof(Win32RGBQuad), 1, out);
|
||||
}
|
||||
|
||||
diff --git a/icotool/extract.c b/icotool/extract.c
|
||||
index f987de4..ad83864 100644
|
||||
--- a/icotool/extract.c
|
||||
+++ b/icotool/extract.c
|
||||
@@ -236,7 +236,7 @@ extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_gen,
|
||||
offset += bitmap.size;
|
||||
|
||||
if (bitmap.clr_used != 0 || bitmap.bit_count < 24) {
|
||||
- palette_count = (bitmap.clr_used != 0 ? bitmap.clr_used : 1 << bitmap.bit_count);
|
||||
+ palette_count = (bitmap.clr_used != 0 ? bitmap.clr_used : (uint32_t) (1 << bitmap.bit_count));
|
||||
if (palette_count > 256) {
|
||||
warn(_("palette too large"));
|
||||
goto done;
|
||||
@@ -319,13 +319,13 @@ extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_gen,
|
||||
|
||||
row = xmalloc(width * 4);
|
||||
|
||||
- for (d = 0; d < height; d++) {
|
||||
+ for (d = 0; d < (uint32_t) height; d++) {
|
||||
uint32_t x;
|
||||
uint32_t y = (bitmap.height < 0 ? d : height - d - 1);
|
||||
uint32_t imod = y * (image_size / height) * 8 / bitmap.bit_count;
|
||||
uint32_t mmod = y * (mask_size / height) * 8;
|
||||
|
||||
- for (x = 0; x < width; x++) {
|
||||
+ for (x = 0; x < (uint32_t) width; x++) {
|
||||
uint32_t color = simple_vec(image_data, x + imod, bitmap.bit_count);
|
||||
|
||||
if (bitmap.bit_count <= 16) {
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,71 +0,0 @@
|
||||
From 7cfc16ecf4727dd0eef1b2d7bfc385435f917c06 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 13:57:27 +0000
|
||||
Subject: [PATCH 13/26] common/common.h: Introduce (more) hygenic definitions
|
||||
of SWAP, min and max macros.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
These contained declarations of variables which shadowed other
|
||||
variable declarations in the main code, leading to warnings like those
|
||||
shown below. I also modified the macros to use parens around all
|
||||
expanded parameters, and added a comment explaining why the values are
|
||||
copied to local variables.
|
||||
|
||||
In file included from ../common/string-utils.h:26:0,
|
||||
from extract.c:46:
|
||||
../common/common.h:29:31: error: declaration of ‘c’ shadows a previous local [-Werror=shadow]
|
||||
#define max(a,b) ({ typeof(a) c = a; typeof(b) d = b; MAX(c,d); })
|
||||
^
|
||||
extract.c:250:40: note: in expansion of macro ‘max’
|
||||
if (abs(bitmap.width) > INT32_MAX/max(4, bitmap.bit_count)) {
|
||||
^~~
|
||||
extract.c:103:11: note: shadowed declaration is here
|
||||
uint32_t c, d;
|
||||
^
|
||||
In file included from ../common/string-utils.h:26:0,
|
||||
from extract.c:46:
|
||||
../common/common.h:29:48: error: declaration of ‘d’ shadows a previous local [-Werror=shadow]
|
||||
#define max(a,b) ({ typeof(a) c = a; typeof(b) d = b; MAX(c,d); })
|
||||
^
|
||||
extract.c:250:40: note: in expansion of macro ‘max’
|
||||
if (abs(bitmap.width) > INT32_MAX/max(4, bitmap.bit_count)) {
|
||||
^~~
|
||||
extract.c:103:14: note: shadowed declaration is here
|
||||
uint32_t c, d;
|
||||
^
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
Thanks: Dan Berrange
|
||||
---
|
||||
common/common.h | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/common/common.h b/common/common.h
|
||||
index 5b9af14..e51455c 100644
|
||||
--- a/common/common.h
|
||||
+++ b/common/common.h
|
||||
@@ -19,14 +19,16 @@
|
||||
#ifndef COMMON_COMMON_H
|
||||
#define COMMON_COMMON_H
|
||||
|
||||
-#define SWAP(a,b) ({ typeof(a) t = a; a = b; b = t; })
|
||||
+#define SWAP(a,b) ({ typeof(a) _t = (a); a = (b); (b) = _t; })
|
||||
|
||||
+/* Variant of MIN which evaluates each parameter only once. */
|
||||
#ifndef min
|
||||
-#define min(a,b) ({ typeof(a) c = a; typeof(b) d = b; MIN(c,d); })
|
||||
+#define min(a,b) ({ typeof(a) _c = (a); typeof(b) _d = (b); MIN(_c,_d); })
|
||||
#endif
|
||||
|
||||
+/* Variant of MAX which evaluates each parameter only once. */
|
||||
#ifndef max
|
||||
-#define max(a,b) ({ typeof(a) c = a; typeof(b) d = b; MAX(c,d); })
|
||||
+#define max(a,b) ({ typeof(a) _c = (a); typeof(b) _d = (b); MAX(_c,_d); })
|
||||
#endif
|
||||
|
||||
#define RETURN_IF_DIFFERENT(i1,i2) \
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,57 +0,0 @@
|
||||
From a788dc640fe1184dfe4c5c3dc9de8ecf34375556 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 14:10:29 +0000
|
||||
Subject: [PATCH 14/26] icotool/extract.c: Use correct printf format for
|
||||
uint32_t.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
"%d" is for printing ints only. To print other types, use the macros
|
||||
defined in the portable <inttypes.h> header. For uint32_t the correct
|
||||
way is "%"PRIu32.
|
||||
|
||||
Warnings were all of the form shown below:
|
||||
|
||||
extract.c:356:16: error: format ‘%d’ expects argument of type ‘int’, but argument 7 has type ‘uint32_t {aka unsigned int}’ [-Werror=format=]
|
||||
printf(_("--%s --index=%d --width=%d --height=%d --bit-depth=%d --palette-size=%d"),
|
||||
^
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
icotool/extract.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/icotool/extract.c b/icotool/extract.c
|
||||
index ad83864..cb8b5dc 100644
|
||||
--- a/icotool/extract.c
|
||||
+++ b/icotool/extract.c
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <stdint.h> /* POSIX/Gnulib */
|
||||
#include <stdlib.h> /* C89 */
|
||||
#include <stdio.h> /* C89 */
|
||||
+#include <inttypes.h>
|
||||
#if HAVE_PNG_H
|
||||
# include <png.h>
|
||||
#else
|
||||
@@ -183,7 +184,7 @@ extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_gen,
|
||||
matched++;
|
||||
|
||||
if (listmode) {
|
||||
- printf(_("--%s --index=%d --width=%d --height=%d --bit-depth=%d --palette-size=%d"),
|
||||
+ printf(_("--%s --index=%d --width=%d --height=%d --bit-depth=%" PRIu32 " --palette-size=%" PRIu32),
|
||||
(dir.type == 1 ? "icon" : "cursor"), completed, width, height,
|
||||
bit_count, palette_count);
|
||||
if (dir.type == 2)
|
||||
@@ -352,7 +353,7 @@ extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_gen,
|
||||
}
|
||||
|
||||
if (listmode) {
|
||||
- printf(_("--%s --index=%d --width=%d --height=%d --bit-depth=%d --palette-size=%d"),
|
||||
+ printf(_("--%s --index=%d --width=%d --height=%d --bit-depth=%" PRIu32 " --palette-size=%" PRIu32),
|
||||
(dir.type == 1 ? "icon" : "cursor"), completed, width, height,
|
||||
bitmap.bit_count, palette_count);
|
||||
if (dir.type == 2)
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,27 +0,0 @@
|
||||
From 9f7acd55ae6fee626563ae2c194522f7f74e47b0 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 14:20:09 +0000
|
||||
Subject: [PATCH 15/26] icotool/main.c: Fix const-correctness of short options
|
||||
string.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
icotool/main.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/icotool/main.c b/icotool/main.c
|
||||
index ec63017..271a5ee 100644
|
||||
--- a/icotool/main.c
|
||||
+++ b/icotool/main.c
|
||||
@@ -66,7 +66,7 @@ enum {
|
||||
CURSOR_OPT,
|
||||
};
|
||||
|
||||
-static char *short_opts = "xlco:i:w:h:p:b:X:Y:t:r:";
|
||||
+static const char *short_opts = "xlco:i:w:h:p:b:X:Y:t:r:";
|
||||
static struct option long_opts[] = {
|
||||
{ "extract", no_argument, NULL, 'x' },
|
||||
{ "list", no_argument, NULL, 'l' },
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,108 +0,0 @@
|
||||
From eb26a4fa5432a0bd16b36663d80c7469bce603f8 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 14:20:57 +0000
|
||||
Subject: [PATCH 16/26] icotool: Fix const-correctness of handling in and out
|
||||
filenames.
|
||||
|
||||
This change is mostly straightforward, but I had to change the
|
||||
prototype of the 'extract_outfile_gen' function so that it doesn't try
|
||||
to overload the meaning of the 'char **outname_ptr' parameter. The
|
||||
(const) input name is placed in a separate parameter.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
icotool/extract.c | 8 +++-----
|
||||
icotool/icotool.h | 4 ++--
|
||||
icotool/main.c | 10 ++++------
|
||||
3 files changed, 9 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/icotool/extract.c b/icotool/extract.c
|
||||
index cb8b5dc..8bbf5c7 100644
|
||||
--- a/icotool/extract.c
|
||||
+++ b/icotool/extract.c
|
||||
@@ -95,7 +95,7 @@ static void png_read_mem (png_structp png, png_bytep data, png_size_t size)
|
||||
|
||||
|
||||
int
|
||||
-extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_gen, ExtractFilter filter)
|
||||
+extract_icons(FILE *in, const char *inname, bool listmode, ExtractNameGen outfile_gen, ExtractFilter filter)
|
||||
{
|
||||
Win32CursorIconFileDir dir;
|
||||
Win32CursorIconFileDirEntry *entries = NULL;
|
||||
@@ -191,8 +191,7 @@ extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_gen,
|
||||
printf(_(" --hotspot-x=%d --hotspot-y=%d"), entries[c].hotspot_x, entries[c].hotspot_y);
|
||||
printf("\n");
|
||||
} else {
|
||||
- outname = inname;
|
||||
- out = outfile_gen(&outname, width, height, bit_count, completed);
|
||||
+ out = outfile_gen(inname, &outname, width, height, bit_count, completed);
|
||||
restore_message_header();
|
||||
set_message_header(outname);
|
||||
|
||||
@@ -296,8 +295,7 @@ extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_gen,
|
||||
goto done;
|
||||
}
|
||||
|
||||
- outname = inname;
|
||||
- out = outfile_gen(&outname, width, height, bitmap.bit_count, completed);
|
||||
+ out = outfile_gen(inname, &outname, width, height, bitmap.bit_count, completed);
|
||||
restore_message_header();
|
||||
set_message_header(outname);
|
||||
|
||||
diff --git a/icotool/icotool.h b/icotool/icotool.h
|
||||
index ba2fbbd..35c2a45 100644
|
||||
--- a/icotool/icotool.h
|
||||
+++ b/icotool/icotool.h
|
||||
@@ -36,9 +36,9 @@ uint32_t palette_lookup(Palette *palette, uint8_t r, uint8_t g, uint8_t b);
|
||||
uint32_t palette_count(Palette *palette);
|
||||
|
||||
/* extract.c */
|
||||
-typedef FILE *(*ExtractNameGen)(char **outname, int width, int height, int bitcount, int index);
|
||||
+typedef FILE *(*ExtractNameGen)(const char *inname, char **outname, int width, int height, int bitcount, int index);
|
||||
typedef bool (*ExtractFilter)(int index, int width, int height, int bitdepth, int palettesize, bool icon, int hotspot_x, int hotspot_y);
|
||||
-int extract_icons(FILE *in, char *inname, bool listmode, ExtractNameGen outfile_gen, ExtractFilter filter);
|
||||
+int extract_icons(FILE *in, const char *inname, bool listmode, ExtractNameGen outfile_gen, ExtractFilter filter);
|
||||
|
||||
/* create.c */
|
||||
typedef FILE *(*CreateNameGen)(char **outname);
|
||||
diff --git a/icotool/main.c b/icotool/main.c
|
||||
index 271a5ee..01e62f5 100644
|
||||
--- a/icotool/main.c
|
||||
+++ b/icotool/main.c
|
||||
@@ -127,13 +127,11 @@ create_outfile_gen(char **out)
|
||||
}
|
||||
|
||||
static FILE *
|
||||
-extract_outfile_gen(char **outname_ptr, int w, int h, int bc, int i)
|
||||
+extract_outfile_gen(const char *inname, char **outname_ptr, int w, int h, int bc, int i)
|
||||
{
|
||||
- char *inname = *outname_ptr;
|
||||
-
|
||||
if (output == NULL || is_directory(output)) {
|
||||
StrBuf *outname;
|
||||
- char *inbase;
|
||||
+ const char *inbase;
|
||||
|
||||
outname = strbuf_new();
|
||||
if (output != NULL) {
|
||||
@@ -192,7 +190,7 @@ display_help(void)
|
||||
}
|
||||
|
||||
static bool
|
||||
-open_file_or_stdin(char *name, FILE **outfile, char **outname)
|
||||
+open_file_or_stdin(char *name, FILE **outfile, const char **outname)
|
||||
{
|
||||
if (strcmp(name, "-") == 0) {
|
||||
*outfile = stdin;
|
||||
@@ -216,7 +214,7 @@ main(int argc, char **argv)
|
||||
bool extract_mode = false;
|
||||
bool create_mode = false;
|
||||
FILE *in;
|
||||
- char *inname;
|
||||
+ const char *inname;
|
||||
size_t raw_filec = 0;
|
||||
char** raw_filev = 0;
|
||||
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,40 +0,0 @@
|
||||
From b05980b0dbf470f7b2d952de36336119ae7dac12 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 14:24:22 +0000
|
||||
Subject: [PATCH 17/26] icotool: Note that we are ignoring errors in
|
||||
palette_lookup function.
|
||||
|
||||
Previously palette_lookup could return -1 for error. This was
|
||||
assigned to uint32_t (thus provoking a warning from GCC), but the
|
||||
error condition was never checked so 0xffffffff would end up being
|
||||
assigned to the output icon.
|
||||
|
||||
This change just makes what we are doing here more explicit, but does
|
||||
not change the semantics.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
icotool/palette.c | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/icotool/palette.c b/icotool/palette.c
|
||||
index a2f4f3d..8e8c57f 100644
|
||||
--- a/icotool/palette.c
|
||||
+++ b/icotool/palette.c
|
||||
@@ -125,7 +125,12 @@ palette_lookup(Palette *palette, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
PaletteColor color = { r, g, b, 0 };
|
||||
PaletteColor *real_color = hmap_get(palette->map, &color);
|
||||
- return (real_color != NULL ? real_color->index : -1);
|
||||
+ /* The caller doesn't handle this as an error, but simply
|
||||
+ * assigns 0xffffffff as a colour in the output.
|
||||
+ */
|
||||
+ if (real_color == NULL)
|
||||
+ return (uint32_t)-1;
|
||||
+ return real_color->index;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,29 +0,0 @@
|
||||
From 7168c1b7b738bb4a4fb330e3c36b4fe82f199987 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 14:56:51 +0000
|
||||
Subject: [PATCH 18/26] wrestool/main.c: Cast RES_TYPE_COUNT to int.
|
||||
|
||||
This avoids a signed/unsigned comparison warning, and is quite safe
|
||||
since the number of entries in the array will always be small.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
wrestool/main.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wrestool/main.c b/wrestool/main.c
|
||||
index a5c6688..218bbbd 100644
|
||||
--- a/wrestool/main.c
|
||||
+++ b/wrestool/main.c
|
||||
@@ -62,7 +62,7 @@ static char *res_types[] = {
|
||||
"version", "dlginclude", NULL, "plugplay", "vxd",
|
||||
"anicursor", "aniicon"
|
||||
};
|
||||
-#define RES_TYPE_COUNT (sizeof(res_types)/sizeof(char *))
|
||||
+#define RES_TYPE_COUNT ((int)(sizeof(res_types)/sizeof(char *)))
|
||||
|
||||
static char *res_type_string_to_id (char *);
|
||||
static char *get_extract_extension (char *);
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,41 +0,0 @@
|
||||
From a02943b9d88473db80ab2bd97ae0bab107603744 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 14:35:41 +0000
|
||||
Subject: [PATCH 19/26] wrestool/restable.c: Const-correctness for
|
||||
find_resource function.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
wrestool/restable.c | 2 +-
|
||||
wrestool/wrestool.h | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/wrestool/restable.c b/wrestool/restable.c
|
||||
index c60806f..fa781f0 100644
|
||||
--- a/wrestool/restable.c
|
||||
+++ b/wrestool/restable.c
|
||||
@@ -542,7 +542,7 @@ find_with_resource_array(WinLibrary *fi, WinResource *wr, char *id)
|
||||
}
|
||||
|
||||
WinResource *
|
||||
-find_resource (WinLibrary *fi, char *type, char *name, char *language, int *level)
|
||||
+find_resource (WinLibrary *fi, const char *type, const char *name, const char *language, int *level)
|
||||
{
|
||||
WinResource *wr;
|
||||
|
||||
diff --git a/wrestool/wrestool.h b/wrestool/wrestool.h
|
||||
index 111f7b1..635a0ef 100644
|
||||
--- a/wrestool/wrestool.h
|
||||
+++ b/wrestool/wrestool.h
|
||||
@@ -91,7 +91,7 @@ typedef void (*DoResourceCallback) (WinLibrary *, WinResource *, WinResource *,
|
||||
/* resource.c */
|
||||
/* WinResource *list_resources (WinLibrary *, WinResource *, int *); */
|
||||
bool read_library (WinLibrary *);
|
||||
-WinResource *find_resource (WinLibrary *, char *, char *, char *, int *);
|
||||
+WinResource *find_resource (WinLibrary *, const char *, const char *, const char *, int *);
|
||||
void *get_resource_entry (WinLibrary *, WinResource *, int *);
|
||||
void do_resources (WinLibrary *, char *, char *, char *, DoResourceCallback);
|
||||
void print_resources_callback (WinLibrary *, WinResource *, WinResource *, WinResource *, WinResource *);
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,150 +0,0 @@
|
||||
From cc0b474840c76dab5091d0a0f0d16e330aff4e6b Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 14:43:37 +0000
|
||||
Subject: [PATCH 20/26] wrestool: Use size_t for resource size.
|
||||
|
||||
The resource size returned by get_resource_entry comes from
|
||||
Win32ImageResourceDataEntry.size which has type uint32_t. Even on 32
|
||||
bit machines, int is not large enough to store this size without
|
||||
overflowing.
|
||||
|
||||
We could use uint32_t here to match what the Windows file gives us.
|
||||
However since this represents the size of a C object in our memory
|
||||
space, it's safer still to use size_t because that can never overflow
|
||||
(notice that along some paths we add to the size).
|
||||
---
|
||||
wrestool/extract.c | 19 ++++++++++---------
|
||||
wrestool/restable.c | 7 ++++---
|
||||
wrestool/wrestool.h | 4 ++--
|
||||
3 files changed, 16 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/wrestool/extract.c b/wrestool/extract.c
|
||||
index a0c516c..e1140a3 100644
|
||||
--- a/wrestool/extract.c
|
||||
+++ b/wrestool/extract.c
|
||||
@@ -28,15 +28,15 @@
|
||||
#include "fileread.h"
|
||||
#include "wrestool.h"
|
||||
|
||||
-static void *extract_group_icon_cursor_resource(WinLibrary *, WinResource *, char *, int *, bool);
|
||||
-static void *extract_bitmap_resource(WinLibrary *, WinResource *, int *);
|
||||
+static void *extract_group_icon_cursor_resource(WinLibrary *, WinResource *, char *, size_t *, bool);
|
||||
+static void *extract_bitmap_resource(WinLibrary *, WinResource *, size_t *);
|
||||
|
||||
void
|
||||
extract_resources_callback (WinLibrary *fi, WinResource *wr,
|
||||
WinResource *type_wr, WinResource *name_wr,
|
||||
WinResource *lang_wr)
|
||||
{
|
||||
- int size;
|
||||
+ size_t size;
|
||||
bool free_it;
|
||||
void *memory;
|
||||
char *outname;
|
||||
@@ -75,7 +75,7 @@ extract_resources_callback (WinLibrary *fi, WinResource *wr,
|
||||
* Extract a resource, returning pointer to data.
|
||||
*/
|
||||
void *
|
||||
-extract_resource (WinLibrary *fi, WinResource *wr, int *size,
|
||||
+extract_resource (WinLibrary *fi, WinResource *wr, size_t *size,
|
||||
bool *free_it, char *type, char *lang, bool raw)
|
||||
{
|
||||
char *str;
|
||||
@@ -123,12 +123,13 @@ extract_resource (WinLibrary *fi, WinResource *wr, int *size,
|
||||
*/
|
||||
static void *
|
||||
extract_group_icon_cursor_resource(WinLibrary *fi, WinResource *wr, char *lang,
|
||||
- int *ressize, bool is_icon)
|
||||
+ size_t *ressize, bool is_icon)
|
||||
{
|
||||
Win32CursorIconDir *icondir;
|
||||
Win32CursorIconFileDir *fileicondir;
|
||||
char *memory;
|
||||
- int c, size, offset, skipped;
|
||||
+ int c, offset, skipped;
|
||||
+ size_t size;
|
||||
|
||||
/* get resource data and size */
|
||||
icondir = (Win32CursorIconDir *) get_resource_entry(fi, wr, &size);
|
||||
@@ -142,7 +143,7 @@ extract_group_icon_cursor_resource(WinLibrary *fi, WinResource *wr, char *lang,
|
||||
skipped = 0;
|
||||
for (c = 0 ; c < icondir->count ; c++) {
|
||||
int level;
|
||||
- int iconsize;
|
||||
+ size_t iconsize;
|
||||
char name[14];
|
||||
WinResource *fwr;
|
||||
|
||||
@@ -265,13 +266,13 @@ extract_group_icon_cursor_resource(WinLibrary *fi, WinResource *wr, char *lang,
|
||||
* the returned memory block will be placed.
|
||||
*/
|
||||
static void *
|
||||
-extract_bitmap_resource(WinLibrary *fi, WinResource *wr, int *ressize)
|
||||
+extract_bitmap_resource(WinLibrary *fi, WinResource *wr, size_t *ressize)
|
||||
{
|
||||
Win32BitmapInfoHeader info;
|
||||
uint8_t *result;
|
||||
uint8_t *resentry;
|
||||
uint32_t offbits;
|
||||
- int size;
|
||||
+ size_t size;
|
||||
|
||||
resentry=(uint8_t *)(get_resource_entry(fi,wr,&size));
|
||||
|
||||
diff --git a/wrestool/restable.c b/wrestool/restable.c
|
||||
index fa781f0..1547979 100644
|
||||
--- a/wrestool/restable.c
|
||||
+++ b/wrestool/restable.c
|
||||
@@ -117,7 +117,8 @@ print_resources_callback (WinLibrary *fi, WinResource *wr,
|
||||
WinResource *lang_wr)
|
||||
{
|
||||
char *type, *offset;
|
||||
- int32_t id, size;
|
||||
+ int32_t id;
|
||||
+ size_t size;
|
||||
|
||||
/* get named resource type if possible */
|
||||
type = NULL;
|
||||
@@ -129,7 +130,7 @@ print_resources_callback (WinLibrary *fi, WinResource *wr,
|
||||
if (offset == NULL)
|
||||
return;
|
||||
|
||||
- printf(_("--type=%s --name=%s%s%s [%s%s%soffset=0x%x size=%d]\n"),
|
||||
+ printf(_("--type=%s --name=%s%s%s [%s%s%soffset=0x%x size=%zu]\n"),
|
||||
get_resource_id_quoted(type_wr),
|
||||
get_resource_id_quoted(name_wr),
|
||||
(lang_wr->id[0] != '\0' ? _(" --language=") : ""),
|
||||
@@ -203,7 +204,7 @@ decode_pe_resource_id (WinLibrary *fi, WinResource *wr, uint32_t value)
|
||||
}
|
||||
|
||||
void *
|
||||
-get_resource_entry (WinLibrary *fi, WinResource *wr, int *size)
|
||||
+get_resource_entry (WinLibrary *fi, WinResource *wr, size_t *size)
|
||||
{
|
||||
if (fi->is_PE_binary) {
|
||||
Win32ImageResourceDataEntry *dataent;
|
||||
diff --git a/wrestool/wrestool.h b/wrestool/wrestool.h
|
||||
index 635a0ef..e4bae73 100644
|
||||
--- a/wrestool/wrestool.h
|
||||
+++ b/wrestool/wrestool.h
|
||||
@@ -92,7 +92,7 @@ typedef void (*DoResourceCallback) (WinLibrary *, WinResource *, WinResource *,
|
||||
/* WinResource *list_resources (WinLibrary *, WinResource *, int *); */
|
||||
bool read_library (WinLibrary *);
|
||||
WinResource *find_resource (WinLibrary *, const char *, const char *, const char *, int *);
|
||||
-void *get_resource_entry (WinLibrary *, WinResource *, int *);
|
||||
+void *get_resource_entry (WinLibrary *, WinResource *, size_t *);
|
||||
void do_resources (WinLibrary *, char *, char *, char *, DoResourceCallback);
|
||||
void print_resources_callback (WinLibrary *, WinResource *, WinResource *, WinResource *, WinResource *);
|
||||
/* bool compare_resource_id (WinResource *, char *); */
|
||||
@@ -102,7 +102,7 @@ char *res_type_id_to_string (int);
|
||||
char *get_destination_name (WinLibrary *, char *, char *, char *);
|
||||
|
||||
/* extract.c */
|
||||
-void *extract_resource (WinLibrary *, WinResource *, int *, bool *, char *, char *, bool);
|
||||
+void *extract_resource (WinLibrary *, WinResource *, size_t *, bool *, char *, char *, bool);
|
||||
void extract_resources_callback (WinLibrary *, WinResource *, WinResource *, WinResource *, WinResource *);
|
||||
|
||||
#endif
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,193 +0,0 @@
|
||||
From f1bf2a86a69f93a03844a5fdf3ff97187556fdf7 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 14:55:33 +0000
|
||||
Subject: [PATCH 21/26] wrestool: Const-correctness in command line argument
|
||||
handling.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
wrestool/extract.c | 2 +-
|
||||
wrestool/main.c | 30 +++++++++++++++---------------
|
||||
wrestool/restable.c | 18 +++++++++---------
|
||||
wrestool/wrestool.h | 6 +++---
|
||||
4 files changed, 28 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/wrestool/extract.c b/wrestool/extract.c
|
||||
index e1140a3..0044ce0 100644
|
||||
--- a/wrestool/extract.c
|
||||
+++ b/wrestool/extract.c
|
||||
@@ -39,7 +39,7 @@ extract_resources_callback (WinLibrary *fi, WinResource *wr,
|
||||
size_t size;
|
||||
bool free_it;
|
||||
void *memory;
|
||||
- char *outname;
|
||||
+ const char *outname;
|
||||
FILE *out;
|
||||
|
||||
memory = extract_resource(fi, wr, &size, &free_it, type_wr->id, (lang_wr == NULL ? NULL : lang_wr->id), arg_raw);
|
||||
diff --git a/wrestool/main.c b/wrestool/main.c
|
||||
index 218bbbd..4c33ba9 100644
|
||||
--- a/wrestool/main.c
|
||||
+++ b/wrestool/main.c
|
||||
@@ -47,12 +47,12 @@ const char version_etc_copyright[] = "Copyright (C) 1998 Oskar Liljeblad";
|
||||
bool arg_raw;
|
||||
static FILE *verbose_file;
|
||||
static int arg_verbosity;
|
||||
-static char *arg_output;
|
||||
-static char *arg_type;
|
||||
-static char *arg_name;
|
||||
-static char *arg_language;
|
||||
+static const char *arg_output;
|
||||
+static const char *arg_type;
|
||||
+static const char *arg_name;
|
||||
+static const char *arg_language;
|
||||
static int arg_action;
|
||||
-static char *res_types[] = {
|
||||
+static const char *res_types[] = {
|
||||
/* 0x01: */
|
||||
"cursor", "bitmap", "icon", "menu", "dialog", "string",
|
||||
"fontdir", "font", "accelerator", "rcdata", "messagelist",
|
||||
@@ -64,14 +64,14 @@ static char *res_types[] = {
|
||||
};
|
||||
#define RES_TYPE_COUNT ((int)(sizeof(res_types)/sizeof(char *)))
|
||||
|
||||
-static char *res_type_string_to_id (char *);
|
||||
-static char *get_extract_extension (char *);
|
||||
+static const char *res_type_string_to_id (const char *);
|
||||
+static const char *get_extract_extension (const char *);
|
||||
|
||||
/* res_type_id_to_string:
|
||||
* Translate a numeric resource type to it's corresponding string type.
|
||||
* (For informative-ness.)
|
||||
*/
|
||||
-char *
|
||||
+const char *
|
||||
res_type_id_to_string (int id)
|
||||
{
|
||||
if (id == 241)
|
||||
@@ -85,10 +85,10 @@ res_type_id_to_string (int id)
|
||||
* Translate a resource type string to integer.
|
||||
* (Used to convert the --type option.)
|
||||
*/
|
||||
-static char *
|
||||
-res_type_string_to_id (char *type)
|
||||
+static const char *
|
||||
+res_type_string_to_id (const char *type)
|
||||
{
|
||||
- static char *res_type_ids[] = {
|
||||
+ static const char *res_type_ids[] = {
|
||||
"-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9", "-10",
|
||||
"-11", "-12", NULL, "-14", NULL, "-16", "-17", NULL, "-19",
|
||||
"-20", "-21", "-22"
|
||||
@@ -110,8 +110,8 @@ res_type_string_to_id (char *type)
|
||||
* Return extension for files of a certain resource type
|
||||
*
|
||||
*/
|
||||
-static char *
|
||||
-get_extract_extension (char *type)
|
||||
+static const char *
|
||||
+get_extract_extension (const char *type)
|
||||
{
|
||||
uint16_t value;
|
||||
|
||||
@@ -134,8 +134,8 @@ get_extract_extension (char *type)
|
||||
/* get_destination_name:
|
||||
* Make a filename for a resource that is to be extracted.
|
||||
*/
|
||||
-char *
|
||||
-get_destination_name (WinLibrary *fi, char *type, char *name, char *lang)
|
||||
+const char *
|
||||
+get_destination_name (WinLibrary *fi, const char *type, const char *name, const char *lang)
|
||||
{
|
||||
static char filename[1024];
|
||||
|
||||
diff --git a/wrestool/restable.c b/wrestool/restable.c
|
||||
index 1547979..df0ffd5 100644
|
||||
--- a/wrestool/restable.c
|
||||
+++ b/wrestool/restable.c
|
||||
@@ -35,11 +35,11 @@ static WinResource *list_ne_type_resources (WinLibrary *, int *);
|
||||
static WinResource *list_ne_name_resources (WinLibrary *, WinResource *, int *);
|
||||
static WinResource *list_pe_resources (WinLibrary *, Win32ImageResourceDirectory *, int, int *);
|
||||
static int calc_vma_size (WinLibrary *);
|
||||
-static void do_resources_recurs (WinLibrary *, WinResource *, WinResource *, WinResource *, WinResource *, char *, char *, char *, DoResourceCallback);
|
||||
+static void do_resources_recurs (WinLibrary *, WinResource *, WinResource *, WinResource *, WinResource *, const char *, const char *, const char *, DoResourceCallback);
|
||||
static char *get_resource_id_quoted (WinResource *);
|
||||
-static WinResource *find_with_resource_array(WinLibrary *, WinResource *, char *);
|
||||
+static WinResource *find_with_resource_array(WinLibrary *, WinResource *, const char *);
|
||||
static WinResource *list_resources (WinLibrary *fi, WinResource *res, int *count);
|
||||
-static bool compare_resource_id (WinResource *wr, char *id);
|
||||
+static bool compare_resource_id (WinResource *wr, const char *id);
|
||||
|
||||
/* Check whether access to a PE_SECTIONS is allowed */
|
||||
#define RETURN_IF_BAD_PE_SECTIONS(ret, module) \
|
||||
@@ -53,7 +53,7 @@ static bool compare_resource_id (WinResource *wr, char *id);
|
||||
*/
|
||||
|
||||
void
|
||||
-do_resources (WinLibrary *fi, char *type, char *name, char *lang, DoResourceCallback cb)
|
||||
+do_resources (WinLibrary *fi, const char *type, const char *name, const char *lang, DoResourceCallback cb)
|
||||
{
|
||||
WinResource *type_wr;
|
||||
WinResource *name_wr;
|
||||
@@ -77,8 +77,8 @@ do_resources (WinLibrary *fi, char *type, char *name, char *lang, DoResourceCall
|
||||
|
||||
static void
|
||||
do_resources_recurs (WinLibrary *fi, WinResource *base, WinResource *type_wr,
|
||||
- WinResource *name_wr, WinResource *lang_wr,
|
||||
- char *type, char *name, char *lang, DoResourceCallback cb)
|
||||
+ WinResource *name_wr, WinResource *lang_wr,
|
||||
+ const char *type, const char *name, const char *lang, DoResourceCallback cb)
|
||||
{
|
||||
int c, rescnt;
|
||||
WinResource *wr;
|
||||
@@ -116,7 +116,7 @@ print_resources_callback (WinLibrary *fi, WinResource *wr,
|
||||
WinResource *type_wr, WinResource *name_wr,
|
||||
WinResource *lang_wr)
|
||||
{
|
||||
- char *type, *offset;
|
||||
+ const char *type, *offset;
|
||||
int32_t id;
|
||||
size_t size;
|
||||
|
||||
@@ -155,7 +155,7 @@ get_resource_id_quoted (WinResource *wr)
|
||||
}
|
||||
|
||||
static bool
|
||||
-compare_resource_id (WinResource *wr, char *id)
|
||||
+compare_resource_id (WinResource *wr, const char *id)
|
||||
{
|
||||
if (wr->numeric_id) {
|
||||
int32_t cmp1, cmp2;
|
||||
@@ -518,7 +518,7 @@ calc_vma_size (WinLibrary *fi)
|
||||
}
|
||||
|
||||
static WinResource *
|
||||
-find_with_resource_array(WinLibrary *fi, WinResource *wr, char *id)
|
||||
+find_with_resource_array(WinLibrary *fi, WinResource *wr, const char *id)
|
||||
{
|
||||
int c, rescnt;
|
||||
WinResource *return_wr;
|
||||
diff --git a/wrestool/wrestool.h b/wrestool/wrestool.h
|
||||
index e4bae73..a3543a3 100644
|
||||
--- a/wrestool/wrestool.h
|
||||
+++ b/wrestool/wrestool.h
|
||||
@@ -93,13 +93,13 @@ typedef void (*DoResourceCallback) (WinLibrary *, WinResource *, WinResource *,
|
||||
bool read_library (WinLibrary *);
|
||||
WinResource *find_resource (WinLibrary *, const char *, const char *, const char *, int *);
|
||||
void *get_resource_entry (WinLibrary *, WinResource *, size_t *);
|
||||
-void do_resources (WinLibrary *, char *, char *, char *, DoResourceCallback);
|
||||
+void do_resources (WinLibrary *, const char *, const char *, const char *, DoResourceCallback);
|
||||
void print_resources_callback (WinLibrary *, WinResource *, WinResource *, WinResource *, WinResource *);
|
||||
/* bool compare_resource_id (WinResource *, char *); */
|
||||
|
||||
/* main.c */
|
||||
-char *res_type_id_to_string (int);
|
||||
-char *get_destination_name (WinLibrary *, char *, char *, char *);
|
||||
+const char *res_type_id_to_string (int);
|
||||
+const char *get_destination_name (WinLibrary *, const char *, const char *, const char *);
|
||||
|
||||
/* extract.c */
|
||||
void *extract_resource (WinLibrary *, WinResource *, size_t *, bool *, char *, char *, bool);
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,36 +0,0 @@
|
||||
From b4ad077a134be781d8e973ded678e927de1cc733 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 15:01:02 +0000
|
||||
Subject: [PATCH 22/26] wrestool/restable.c: Use PRIu32 when printing a
|
||||
uint32_t.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
restable.c: In function ‘decode_pe_resource_id’:
|
||||
restable.c:199:40: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t {aka unsigned int}’ [-Werror=format=]
|
||||
snprintf(wr->id, WINRES_ID_MAXLEN, "%d", value);
|
||||
~^
|
||||
%d
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
wrestool/restable.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wrestool/restable.c b/wrestool/restable.c
|
||||
index df0ffd5..4a9f36a 100644
|
||||
--- a/wrestool/restable.c
|
||||
+++ b/wrestool/restable.c
|
||||
@@ -196,7 +196,7 @@ decode_pe_resource_id (WinLibrary *fi, WinResource *wr, uint32_t value)
|
||||
wr->id[len] = '\0';
|
||||
} else { /* Unicode string id */
|
||||
/* translate id into a string */
|
||||
- snprintf(wr->id, WINRES_ID_MAXLEN, "%d", value);
|
||||
+ snprintf(wr->id, WINRES_ID_MAXLEN, "%" PRIu32, value);
|
||||
}
|
||||
|
||||
wr->numeric_id = (value & IMAGE_RESOURCE_NAME_IS_STRING ? false:true);
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,37 +0,0 @@
|
||||
From 101f6c7c87003fa0d20f25a7c17e42a008e38d47 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 15:06:46 +0000
|
||||
Subject: [PATCH 23/26] wrestool/restable.c: Use size_t when counting array
|
||||
elements.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Original warning from GCC:
|
||||
|
||||
restable.c: In function ‘list_resources’:
|
||||
restable.c:343:2: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
|
||||
for (c = 0 ; c < rescnt ; c++) {
|
||||
^~~
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
wrestool/restable.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wrestool/restable.c b/wrestool/restable.c
|
||||
index 4a9f36a..8226806 100644
|
||||
--- a/wrestool/restable.c
|
||||
+++ b/wrestool/restable.c
|
||||
@@ -318,7 +318,7 @@ list_ne_name_resources (WinLibrary *fi, WinResource *typeres, int *count)
|
||||
static WinResource *
|
||||
list_ne_type_resources (WinLibrary *fi, int *count)
|
||||
{
|
||||
- int c, rescnt;
|
||||
+ size_t c, rescnt;
|
||||
WinResource *wr;
|
||||
Win16NETypeInfo *typeinfo;
|
||||
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,27 +0,0 @@
|
||||
From 88634ac7faff5126d256cc06dfcc3d1afa060940 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 15:09:35 +0000
|
||||
Subject: [PATCH 24/26] wrestool/restable.c: Use size_t when calculating sizes
|
||||
of objects in memory.
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
wrestool/restable.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wrestool/restable.c b/wrestool/restable.c
|
||||
index 8226806..fd0ba49 100644
|
||||
--- a/wrestool/restable.c
|
||||
+++ b/wrestool/restable.c
|
||||
@@ -488,7 +488,7 @@ static int
|
||||
calc_vma_size (WinLibrary *fi)
|
||||
{
|
||||
Win32ImageSectionHeader *seg;
|
||||
- int c, segcount, size;
|
||||
+ size_t c, segcount, size;
|
||||
|
||||
size = 0;
|
||||
RETURN_IF_BAD_POINTER(-1, PE_HEADER(fi->memory)->file_header.number_of_sections);
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,58 +0,0 @@
|
||||
From da334f5a8754e164e53686c9399e797f124ba034 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 9 Mar 2017 15:12:16 +0000
|
||||
Subject: [PATCH 25/26] wrestool/fileread: Fix check_offset to be const-correct
|
||||
and use size_t.
|
||||
|
||||
Three things were wrong with this function:
|
||||
|
||||
(1) Always use size_t when calculating or storing the size of an
|
||||
object in memory.
|
||||
|
||||
(2) The function wasn't const-correct.
|
||||
|
||||
(3) The function use arithmetic operations on void* pointers (which is
|
||||
not defined in C).
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
wrestool/fileread.c | 9 +++++----
|
||||
wrestool/fileread.h | 2 +-
|
||||
2 files changed, 6 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/wrestool/fileread.c b/wrestool/fileread.c
|
||||
index 0ec7c49..cb0d7a0 100644
|
||||
--- a/wrestool/fileread.c
|
||||
+++ b/wrestool/fileread.c
|
||||
@@ -33,11 +33,12 @@
|
||||
* Usually not called directly.
|
||||
*/
|
||||
bool
|
||||
-check_offset(char *memory, int total_size, char *name, void *offset, int size)
|
||||
+check_offset(const char *memory, size_t total_size,
|
||||
+ const char *name, const void *offset, size_t size)
|
||||
{
|
||||
- char* memory_end = memory + total_size;
|
||||
- char* block = (char*)offset;
|
||||
- char* block_end = offset + size;
|
||||
+ const char* memory_end = memory + total_size;
|
||||
+ const char* block = (const char*) offset;
|
||||
+ const char* block_end = block + size;
|
||||
|
||||
/*debug("check_offset: size=%x vs %x offset=%x size=%x\n",
|
||||
need_size, total_size, (char *) offset - memory, size);*/
|
||||
diff --git a/wrestool/fileread.h b/wrestool/fileread.h
|
||||
index 1cc7358..45ea543 100644
|
||||
--- a/wrestool/fileread.h
|
||||
+++ b/wrestool/fileread.h
|
||||
@@ -33,6 +33,6 @@
|
||||
return (r); \
|
||||
}
|
||||
|
||||
-bool check_offset(char *, int, char *, void *, int);
|
||||
+bool check_offset(const char *, size_t, const char *, const void *, size_t);
|
||||
|
||||
#endif
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,36 +0,0 @@
|
||||
From 418353e7037ec650f3cc261ff0585efab37383cf Mon Sep 17 00:00:00 2001
|
||||
From: Frank Richter <frank.richter@gmail.com>
|
||||
Date: Thu, 9 Mar 2017 20:01:27 +0100
|
||||
Subject: [PATCH 26/26] Updated NEWS, AUTHORS
|
||||
|
||||
---
|
||||
AUTHORS | 4 ++++
|
||||
NEWS | 3 +++
|
||||
2 files changed, 7 insertions(+)
|
||||
|
||||
diff --git a/AUTHORS b/AUTHORS
|
||||
index 4383200..90a9f75 100644
|
||||
--- a/AUTHORS
|
||||
+++ b/AUTHORS
|
||||
@@ -40,3 +40,7 @@ Richard W.M. Jones <rjones@redhat.com>
|
||||
Jerzy Kramarz <op7ica@gmail.com>
|
||||
- pointing out various crashes/bugs exploitable for DoS
|
||||
purposes
|
||||
+
|
||||
+Richard W.M. Jones <rjones@redhat.com>
|
||||
+ - Fixed compiler warnings and made improvements to the
|
||||
+ build scripts.
|
||||
diff --git a/NEWS b/NEWS
|
||||
index b1b9da4..c8ad1a7 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -1,3 +1,6 @@
|
||||
+2017-??-??:
|
||||
+ Warning fixes and build improvements from Richard W.M. Jones <rjones@redhat.com>
|
||||
+
|
||||
2017-03-06: icoutils 0.31.2 released.
|
||||
Various security fixes from Martin Gieseking,
|
||||
issues found by Jerzy Kramarz
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
aclocal -I m4 && autoheader && libtoolize --force -c && automake -a -c && autoconf
|
12
gitignore
12
gitignore
@ -1,12 +0,0 @@
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
common/Makefile.in
|
||||
config.h.in
|
||||
config.h.in~
|
||||
configure
|
||||
extresso/Makefile.in
|
||||
icotool/Makefile.in
|
||||
lib/Makefile.in
|
||||
wrestool/Makefile.in
|
||||
Makefile.in
|
||||
mkinstalldirs
|
@ -1,58 +1,12 @@
|
||||
Name: icoutils
|
||||
Version: 0.31.2
|
||||
Release: 3%{?dist}
|
||||
Version: 0.31.3
|
||||
Release: 1%{?dist}
|
||||
Summary: Utility for extracting and converting Microsoft icon and cursor files
|
||||
|
||||
License: GPLv3+
|
||||
URL: http://www.nongnu.org/icoutils/
|
||||
Source0: http://savannah.nongnu.org/download/%{name}/%{name}-%{version}.tar.bz2
|
||||
|
||||
# Patches (all upsteam after 0.31.2) which enable compiler warnings
|
||||
# and fix multiple problems in the code.
|
||||
#
|
||||
# Unfortunately because these apply to git, and the tarball does not
|
||||
# include certain files from git, to apply the patches easily we must
|
||||
# provide some extra files from upstream.
|
||||
#
|
||||
# All these patches and source files can be removed when 0.31.3 is
|
||||
# released upstream.
|
||||
Source1: bootstrap
|
||||
Source2: gitignore
|
||||
Source3: manywarnings.m4
|
||||
Source4: warnings.m4
|
||||
#
|
||||
Patch0001: 0001-wrestool-Fix-misleading-indentation.patch
|
||||
Patch0002: 0002-gitignore-Use-git-s-pattern-matching-to-make-this-si.patch
|
||||
Patch0003: 0003-gitignore-Ignore-most-generated-files.patch
|
||||
Patch0004: 0004-bootstrap-Use-set-e-to-check-for-errors.patch
|
||||
Patch0005: 0005-bootstrap-Run-gnulib-tool-if-available.patch
|
||||
Patch0006: 0006-configure-Enable-many-more-warnings-and-add-enable-w.patch
|
||||
Patch0007: 0007-common-intutil.c-Avoid-comparison-between-signed-and.patch
|
||||
Patch0008: 0008-common-llist.c-Avoid-unnecessary-comparisons-unsigne.patch
|
||||
Patch0009: 0009-common-strbuf.c-Use-size_t-and-ssize_t.patch
|
||||
Patch0010: 0010-common-tmap.c-Safe-comparison-of-two-pointers.patch
|
||||
Patch0011: 0011-icotool-Use-size_t-when-counting-array-elements-not-.patch
|
||||
Patch0012: 0012-icotool-Fix-some-comparisons-of-signed-unsigned.patch
|
||||
Patch0013: 0013-common-common.h-Introduce-more-hygenic-definitions-o.patch
|
||||
Patch0014: 0014-icotool-extract.c-Use-correct-printf-format-for-uint.patch
|
||||
Patch0015: 0015-icotool-main.c-Fix-const-correctness-of-short-option.patch
|
||||
Patch0016: 0016-icotool-Fix-const-correctness-of-handling-in-and-out.patch
|
||||
Patch0017: 0017-icotool-Note-that-we-are-ignoring-errors-in-palette_.patch
|
||||
Patch0018: 0018-wrestool-main.c-Cast-RES_TYPE_COUNT-to-int.patch
|
||||
Patch0019: 0019-wrestool-restable.c-Const-correctness-for-find_resou.patch
|
||||
Patch0020: 0020-wrestool-Use-size_t-for-resource-size.patch
|
||||
Patch0021: 0021-wrestool-Const-correctness-in-command-line-argument-.patch
|
||||
Patch0022: 0022-wrestool-restable.c-Use-PRIu32-when-printing-a-uint3.patch
|
||||
Patch0023: 0023-wrestool-restable.c-Use-size_t-when-counting-array-e.patch
|
||||
Patch0024: 0024-wrestool-restable.c-Use-size_t-when-calculating-size.patch
|
||||
Patch0025: 0025-wrestool-fileread-Fix-check_offset-to-be-const-corre.patch
|
||||
Patch0026: 0026-Updated-NEWS-AUTHORS.patch
|
||||
|
||||
# This reverts one of the security checks above which breaks wrestool
|
||||
# processing of PE binaries. Under discussion upstream, still no fix
|
||||
# as of 0.31.2.
|
||||
Patch0027: 0001-Revert-Add-additional-sanity-checks-to-do_resource-..patch
|
||||
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: automake
|
||||
BuildRequires: gettext
|
||||
@ -71,12 +25,6 @@ libraries.
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
cp %{SOURCE1} bootstrap
|
||||
cp %{SOURCE2} .gitignore
|
||||
cp %{SOURCE3} m4/manywarnings.m4
|
||||
cp %{SOURCE4} m4/warnings.m4
|
||||
for f in %{patches}; do patch -p1 < $f; done
|
||||
|
||||
autoreconf -i
|
||||
|
||||
for f in AUTHORS NEWS; do
|
||||
@ -105,6 +53,11 @@ make install DESTDIR=%{buildroot}
|
||||
|
||||
|
||||
%changelog
|
||||
* Sun Mar 12 2017 Richard W.M. Jones <rjones@redhat.com> - 0.31.3-1
|
||||
- New upstream version 0.31.3.
|
||||
- This includes all the previous upstream patches, and reverts the
|
||||
check which broke processing of PE binaries.
|
||||
|
||||
* Fri Mar 10 2017 Richard W.M. Jones <rjones@redhat.com> - 0.31.2-3
|
||||
- Add a series of upstream patches to enable compiler warnings and
|
||||
fix multiple issues.
|
||||
|
276
manywarnings.m4
276
manywarnings.m4
@ -1,276 +0,0 @@
|
||||
# manywarnings.m4 serial 8
|
||||
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Simon Josefsson
|
||||
|
||||
# gl_MANYWARN_COMPLEMENT(OUTVAR, LISTVAR, REMOVEVAR)
|
||||
# --------------------------------------------------
|
||||
# Copy LISTVAR to OUTVAR except for the entries in REMOVEVAR.
|
||||
# Elements separated by whitespace. In set logic terms, the function
|
||||
# does OUTVAR = LISTVAR \ REMOVEVAR.
|
||||
AC_DEFUN([gl_MANYWARN_COMPLEMENT],
|
||||
[
|
||||
gl_warn_set=
|
||||
set x $2; shift
|
||||
for gl_warn_item
|
||||
do
|
||||
case " $3 " in
|
||||
*" $gl_warn_item "*)
|
||||
;;
|
||||
*)
|
||||
gl_warn_set="$gl_warn_set $gl_warn_item"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
$1=$gl_warn_set
|
||||
])
|
||||
|
||||
# gl_MANYWARN_ALL_GCC(VARIABLE)
|
||||
# -----------------------------
|
||||
# Add all documented GCC warning parameters to variable VARIABLE.
|
||||
# Note that you need to test them using gl_WARN_ADD if you want to
|
||||
# make sure your gcc understands it.
|
||||
AC_DEFUN([gl_MANYWARN_ALL_GCC],
|
||||
[
|
||||
dnl First, check for some issues that only occur when combining multiple
|
||||
dnl gcc warning categories.
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
if test -n "$GCC"; then
|
||||
|
||||
dnl Check if -W -Werror -Wno-missing-field-initializers is supported
|
||||
dnl with the current $CC $CFLAGS $CPPFLAGS.
|
||||
AC_MSG_CHECKING([whether -Wno-missing-field-initializers is supported])
|
||||
AC_CACHE_VAL([gl_cv_cc_nomfi_supported], [
|
||||
gl_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -W -Werror -Wno-missing-field-initializers"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[]], [[]])],
|
||||
[gl_cv_cc_nomfi_supported=yes],
|
||||
[gl_cv_cc_nomfi_supported=no])
|
||||
CFLAGS="$gl_save_CFLAGS"])
|
||||
AC_MSG_RESULT([$gl_cv_cc_nomfi_supported])
|
||||
|
||||
if test "$gl_cv_cc_nomfi_supported" = yes; then
|
||||
dnl Now check whether -Wno-missing-field-initializers is needed
|
||||
dnl for the { 0, } construct.
|
||||
AC_MSG_CHECKING([whether -Wno-missing-field-initializers is needed])
|
||||
AC_CACHE_VAL([gl_cv_cc_nomfi_needed], [
|
||||
gl_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -W -Werror"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[int f (void)
|
||||
{
|
||||
typedef struct { int a; int b; } s_t;
|
||||
s_t s1 = { 0, };
|
||||
return s1.b;
|
||||
}
|
||||
]],
|
||||
[[]])],
|
||||
[gl_cv_cc_nomfi_needed=no],
|
||||
[gl_cv_cc_nomfi_needed=yes])
|
||||
CFLAGS="$gl_save_CFLAGS"
|
||||
])
|
||||
AC_MSG_RESULT([$gl_cv_cc_nomfi_needed])
|
||||
fi
|
||||
|
||||
dnl Next, check if -Werror -Wuninitialized is useful with the
|
||||
dnl user's choice of $CFLAGS; some versions of gcc warn that it
|
||||
dnl has no effect if -O is not also used
|
||||
AC_MSG_CHECKING([whether -Wuninitialized is supported])
|
||||
AC_CACHE_VAL([gl_cv_cc_uninitialized_supported], [
|
||||
gl_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Werror -Wuninitialized"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[]], [[]])],
|
||||
[gl_cv_cc_uninitialized_supported=yes],
|
||||
[gl_cv_cc_uninitialized_supported=no])
|
||||
CFLAGS="$gl_save_CFLAGS"])
|
||||
AC_MSG_RESULT([$gl_cv_cc_uninitialized_supported])
|
||||
|
||||
fi
|
||||
|
||||
# List all gcc warning categories.
|
||||
# To compare this list to your installed GCC's, run this Bash command:
|
||||
#
|
||||
# comm -3 \
|
||||
# <(sed -n 's/^ *\(-[^ ]*\) .*/\1/p' manywarnings.m4 | sort) \
|
||||
# <(gcc --help=warnings | sed -n 's/^ \(-[^ ]*\) .*/\1/p' | sort |
|
||||
# grep -v -x -f <(
|
||||
# awk '/^[^#]/ {print $1}' ../build-aux/gcc-warning.spec))
|
||||
|
||||
gl_manywarn_set=
|
||||
for gl_manywarn_item in \
|
||||
-fno-common \
|
||||
-W \
|
||||
-Wabi \
|
||||
-Waddress \
|
||||
-Waggressive-loop-optimizations \
|
||||
-Wall \
|
||||
-Wattributes \
|
||||
-Wbad-function-cast \
|
||||
-Wbool-compare \
|
||||
-Wbuiltin-macro-redefined \
|
||||
-Wcast-align \
|
||||
-Wchar-subscripts \
|
||||
-Wchkp \
|
||||
-Wclobbered \
|
||||
-Wcomment \
|
||||
-Wcomments \
|
||||
-Wcoverage-mismatch \
|
||||
-Wcpp \
|
||||
-Wdate-time \
|
||||
-Wdeprecated \
|
||||
-Wdeprecated-declarations \
|
||||
-Wdesignated-init \
|
||||
-Wdisabled-optimization \
|
||||
-Wdiscarded-array-qualifiers \
|
||||
-Wdiscarded-qualifiers \
|
||||
-Wdiv-by-zero \
|
||||
-Wdouble-promotion \
|
||||
-Wduplicated-cond \
|
||||
-Wempty-body \
|
||||
-Wendif-labels \
|
||||
-Wenum-compare \
|
||||
-Wextra \
|
||||
-Wformat-contains-nul \
|
||||
-Wformat-extra-args \
|
||||
-Wformat-nonliteral \
|
||||
-Wformat-security \
|
||||
-Wformat-signedness \
|
||||
-Wformat-y2k \
|
||||
-Wformat-zero-length \
|
||||
-Wframe-address \
|
||||
-Wfree-nonheap-object \
|
||||
-Whsa \
|
||||
-Wignored-attributes \
|
||||
-Wignored-qualifiers \
|
||||
-Wimplicit \
|
||||
-Wimplicit-function-declaration \
|
||||
-Wimplicit-int \
|
||||
-Wincompatible-pointer-types \
|
||||
-Winit-self \
|
||||
-Winline \
|
||||
-Wint-conversion \
|
||||
-Wint-to-pointer-cast \
|
||||
-Winvalid-memory-model \
|
||||
-Winvalid-pch \
|
||||
-Wjump-misses-init \
|
||||
-Wlogical-not-parentheses \
|
||||
-Wlogical-op \
|
||||
-Wmain \
|
||||
-Wmaybe-uninitialized \
|
||||
-Wmemset-transposed-args \
|
||||
-Wmisleading-indentation \
|
||||
-Wmissing-braces \
|
||||
-Wmissing-declarations \
|
||||
-Wmissing-field-initializers \
|
||||
-Wmissing-include-dirs \
|
||||
-Wmissing-parameter-type \
|
||||
-Wmissing-prototypes \
|
||||
-Wmultichar \
|
||||
-Wnarrowing \
|
||||
-Wnested-externs \
|
||||
-Wnonnull \
|
||||
-Wnonnull-compare \
|
||||
-Wnull-dereference \
|
||||
-Wodr \
|
||||
-Wold-style-declaration \
|
||||
-Wold-style-definition \
|
||||
-Wopenmp-simd \
|
||||
-Woverflow \
|
||||
-Woverlength-strings \
|
||||
-Woverride-init \
|
||||
-Wpacked \
|
||||
-Wpacked-bitfield-compat \
|
||||
-Wparentheses \
|
||||
-Wpointer-arith \
|
||||
-Wpointer-sign \
|
||||
-Wpointer-to-int-cast \
|
||||
-Wpragmas \
|
||||
-Wreturn-local-addr \
|
||||
-Wreturn-type \
|
||||
-Wscalar-storage-order \
|
||||
-Wsequence-point \
|
||||
-Wshadow \
|
||||
-Wshift-count-negative \
|
||||
-Wshift-count-overflow \
|
||||
-Wshift-negative-value \
|
||||
-Wsizeof-array-argument \
|
||||
-Wsizeof-pointer-memaccess \
|
||||
-Wstack-protector \
|
||||
-Wstrict-aliasing \
|
||||
-Wstrict-overflow \
|
||||
-Wstrict-prototypes \
|
||||
-Wsuggest-attribute=const \
|
||||
-Wsuggest-attribute=format \
|
||||
-Wsuggest-attribute=noreturn \
|
||||
-Wsuggest-attribute=pure \
|
||||
-Wsuggest-final-methods \
|
||||
-Wsuggest-final-types \
|
||||
-Wswitch \
|
||||
-Wswitch-bool \
|
||||
-Wswitch-default \
|
||||
-Wsync-nand \
|
||||
-Wsystem-headers \
|
||||
-Wtautological-compare \
|
||||
-Wtrampolines \
|
||||
-Wtrigraphs \
|
||||
-Wtype-limits \
|
||||
-Wuninitialized \
|
||||
-Wunknown-pragmas \
|
||||
-Wunsafe-loop-optimizations \
|
||||
-Wunused \
|
||||
-Wunused-but-set-parameter \
|
||||
-Wunused-but-set-variable \
|
||||
-Wunused-function \
|
||||
-Wunused-label \
|
||||
-Wunused-local-typedefs \
|
||||
-Wunused-macros \
|
||||
-Wunused-parameter \
|
||||
-Wunused-result \
|
||||
-Wunused-value \
|
||||
-Wunused-variable \
|
||||
-Wvarargs \
|
||||
-Wvariadic-macros \
|
||||
-Wvector-operation-performance \
|
||||
-Wvla \
|
||||
-Wvolatile-register-var \
|
||||
-Wwrite-strings \
|
||||
\
|
||||
; do
|
||||
gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
|
||||
done
|
||||
|
||||
# gcc --help=warnings outputs an unusual form for these options; list
|
||||
# them here so that the above 'comm' command doesn't report a false match.
|
||||
gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
|
||||
gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc"
|
||||
gl_manywarn_set="$gl_manywarn_set -Wshift-overflow=2"
|
||||
gl_manywarn_set="$gl_manywarn_set -Wunused-const-variable=2"
|
||||
|
||||
# These are needed for older GCC versions.
|
||||
if test -n "$GCC"; then
|
||||
case `($CC --version) 2>/dev/null` in
|
||||
'gcc (GCC) '[[0-3]].* | \
|
||||
'gcc (GCC) '4.[[0-7]].*)
|
||||
gl_manywarn_set="$gl_manywarn_set -fdiagnostics-show-option"
|
||||
gl_manywarn_set="$gl_manywarn_set -funit-at-a-time"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Disable specific options as needed.
|
||||
if test "$gl_cv_cc_nomfi_needed" = yes; then
|
||||
gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
|
||||
fi
|
||||
|
||||
if test "$gl_cv_cc_uninitialized_supported" = no; then
|
||||
gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized"
|
||||
fi
|
||||
|
||||
$1=$gl_manywarn_set
|
||||
])
|
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (icoutils-0.31.2.tar.bz2) = 87149ac539022d1d7a86ab0c1e97fa01cab3f5479484abbad4de74179efd67d7ffe7241ef1e390592ce965f45b64f6c7669eef77a9299cb4bfe7779d691f831b
|
||||
SHA512 (icoutils-0.31.3.tar.bz2) = 3c25dfff0d947ad4688e57871888b7d03ecc1d5aaf2dd957bbfd5d034cbde03238a03446a719b637d2f0c309af424359435d98bddfbdf1ea9d4c08bb23f154d8
|
||||
|
79
warnings.m4
79
warnings.m4
@ -1,79 +0,0 @@
|
||||
# warnings.m4 serial 11
|
||||
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Simon Josefsson
|
||||
|
||||
# gl_AS_VAR_APPEND(VAR, VALUE)
|
||||
# ----------------------------
|
||||
# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
|
||||
m4_ifdef([AS_VAR_APPEND],
|
||||
[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
|
||||
[m4_define([gl_AS_VAR_APPEND],
|
||||
[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
|
||||
|
||||
|
||||
# gl_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED],
|
||||
# [PROGRAM = AC_LANG_PROGRAM()])
|
||||
# -----------------------------------------------------------------
|
||||
# Check if the compiler supports OPTION when compiling PROGRAM.
|
||||
#
|
||||
# FIXME: gl_Warn must be used unquoted until we can assume Autoconf
|
||||
# 2.64 or newer.
|
||||
AC_DEFUN([gl_COMPILER_OPTION_IF],
|
||||
[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
|
||||
AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
|
||||
AS_LITERAL_IF([$1],
|
||||
[m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))],
|
||||
[gl_positive="$1"
|
||||
case $gl_positive in
|
||||
-Wno-*) gl_positive=-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;;
|
||||
esac
|
||||
m4_pushdef([gl_Positive], [$gl_positive])])dnl
|
||||
AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
|
||||
gl_save_compiler_FLAGS="$gl_Flags"
|
||||
gl_AS_VAR_APPEND(m4_defn([gl_Flags]),
|
||||
[" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["])
|
||||
AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])],
|
||||
[AS_VAR_SET(gl_Warn, [yes])],
|
||||
[AS_VAR_SET(gl_Warn, [no])])
|
||||
gl_Flags="$gl_save_compiler_FLAGS"
|
||||
])
|
||||
AS_VAR_IF(gl_Warn, [yes], [$2], [$3])
|
||||
m4_popdef([gl_Positive])dnl
|
||||
AS_VAR_POPDEF([gl_Flags])dnl
|
||||
AS_VAR_POPDEF([gl_Warn])dnl
|
||||
])
|
||||
|
||||
# gl_UNKNOWN_WARNINGS_ARE_ERRORS
|
||||
# ------------------------------
|
||||
# Clang doesn't complain about unknown warning options unless one also
|
||||
# specifies -Wunknown-warning-option -Werror. Detect this.
|
||||
AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS],
|
||||
[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option],
|
||||
[gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'],
|
||||
[gl_unknown_warnings_are_errors=])])
|
||||
|
||||
# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS],
|
||||
# [PROGRAM = AC_LANG_PROGRAM()])
|
||||
# ---------------------------------------------
|
||||
# Adds parameter to WARN_CFLAGS if the compiler supports it when
|
||||
# compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]).
|
||||
#
|
||||
# If VARIABLE is a variable name, AC_SUBST it.
|
||||
AC_DEFUN([gl_WARN_ADD],
|
||||
[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
|
||||
gl_COMPILER_OPTION_IF([$1],
|
||||
[gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])],
|
||||
[],
|
||||
[$3])
|
||||
m4_ifval([$2],
|
||||
[AS_LITERAL_IF([$2], [AC_SUBST([$2])])],
|
||||
[AC_SUBST([WARN_CFLAGS])])dnl
|
||||
])
|
||||
|
||||
# Local Variables:
|
||||
# mode: autoconf
|
||||
# End:
|
Loading…
Reference in New Issue
Block a user