Skip to content

Commit

Permalink
media-libs/kvazaar: backport upstream fix to build with gcc7.
Browse files Browse the repository at this point in the history
Package-Manager: Portage-2.3.6, Repoman-2.3.2
  • Loading branch information
aballier committed Jun 16, 2017
1 parent cec71e4 commit bb4c534
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions media-libs/kvazaar/files/gcc7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
commit 47a9f0de049e77e866ea5bdd4bc7c795ea6dd641
Author: Ari Lemmetti <[email protected]>
Date: Tue Apr 11 12:57:22 2017 +0300

Modify and use FILL_ARRAY macro to prevent warning on GCC 7

Following warning was given and is false positive

error: 'memset' used with length equal to number of elements without multiplication by element size [-Werror=memset-elt-size]

diff --git a/src/global.h b/src/global.h
index bedcd49..5181674 100644
--- a/src/global.h
+++ b/src/global.h
@@ -219,7 +219,11 @@ typedef int16_t coeff_t;
// Fill a structure or a static array with val bytes.
#define FILL(var, val) memset(&(var), (val), sizeof(var))
// Fill a number of elements in an array with val bytes.
-#define FILL_ARRAY(ar, val, size) memset((ar), (val), (size) * sizeof(*(ar)))
+#define FILL_ARRAY(ar, val, size) \
+{\
+ void *temp_ptr = (void*)(ar);\
+ memset((temp_ptr), (val), (size) * sizeof(*(ar)));\
+}

#define FREE_POINTER(pointer) { free((void*)pointer); pointer = NULL; }
#define MOVE_POINTER(dst_pointer,src_pointer) { dst_pointer = src_pointer; src_pointer = NULL; }
diff --git a/src/rdo.c b/src/rdo.c
index 52305fd..2579f28 100644
--- a/src/rdo.c
+++ b/src/rdo.c
@@ -558,10 +558,10 @@ void kvz_rdoq(encoder_state_t * const state, coeff_t *coef, coeff_t *dest_coeff,
// Explicitly tell the only possible numbers of elements to be zeroed.
// Hope the compiler is able to utilize this information.
switch (cg_num) {
- case 1: memset(sig_coeffgroup_flag, 0, 1 * sizeof(sig_coeffgroup_flag[0])); break;
- case 4: memset(sig_coeffgroup_flag, 0, 4 * sizeof(sig_coeffgroup_flag[0])); break;
- case 16: memset(sig_coeffgroup_flag, 0, 16 * sizeof(sig_coeffgroup_flag[0])); break;
- case 64: memset(sig_coeffgroup_flag, 0, 64 * sizeof(sig_coeffgroup_flag[0])); break;
+ case 1: FILL_ARRAY(sig_coeffgroup_flag, 0, 1); break;
+ case 4: FILL_ARRAY(sig_coeffgroup_flag, 0, 4); break;
+ case 16: FILL_ARRAY(sig_coeffgroup_flag, 0, 16); break;
+ case 64: FILL_ARRAY(sig_coeffgroup_flag, 0, 64); break;
default: assert(0 && "There should be 1, 4, 16 or 64 coefficient groups");
}

1 change: 1 addition & 0 deletions media-libs/kvazaar/kvazaar-1.1.0.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ DEPEND="${DEPEND}
abi_x86_64? ( ${ASM_DEP} )"

src_prepare() {
epatch "${FILESDIR}/gcc7.patch"
eautoreconf
if use test && [ "${PV#9999}" = "${PV}" ]; then
# https://bugs.gentoo.org/show_bug.cgi?id=595932
Expand Down

0 comments on commit bb4c534

Please sign in to comment.