From 014773b66bdff4de24f384066d1a85d2a5bb6774 Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Thu, 28 Jul 2016 14:30:25 +0300 Subject: libavutil: Use an intermediate variable in AV_COPY*U MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If AV_RN and AV_WN are macros with multiple individual reads and writes, the previous version of the AV_COPYU macro would fail if the reads and writes overlap. This should not be any less efficient in any case, given a sensibly optimizing compiler. Signed-off-by: Martin Storsjö --- libavutil/intreadwrite.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libavutil') diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h index f77fd60f38..cdf1ef47ec 100644 --- a/libavutil/intreadwrite.h +++ b/libavutil/intreadwrite.h @@ -467,7 +467,11 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; * memory locations. */ -#define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s)); +#define AV_COPYU(n, d, s) \ + do { \ + uint##n##_t val = AV_RN##n(s); \ + AV_WN##n(d, val); \ + } while (0) #ifndef AV_COPY16U # define AV_COPY16U(d, s) AV_COPYU(16, d, s) -- cgit v1.2.3