[2/5] xmv: Don't use expressions with side effects in macro parameters

Message ID 1469706841-90972-2-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö July 28, 2016, 11:53 a.m.
AV_WB32 can be implemented as a macro that expands its parameters
multiple times (in case AV_HAVE_FAST_UNALIGNED isn't set and the
compiler doesn't support GCC attributes); make sure not to read
multiple times from the source in this case.
---
 libavformat/xmv.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Diego Biurrun July 28, 2016, 6:58 p.m. | #1
On Thu, Jul 28, 2016 at 02:53:58PM +0300, Martin Storsjö wrote:
> AV_WB32 can be implemented as a macro that expands its parameters
> multiple times (in case AV_HAVE_FAST_UNALIGNED isn't set and the
> compiler doesn't support GCC attributes); make sure not to read
> multiple times from the source in this case.
> ---
>  libavformat/xmv.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

OK

Diego

Patch

diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index b2112b0..fa39156 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -512,8 +512,10 @@  static int xmv_fetch_video_packet(AVFormatContext *s,
      * WMV2 is little-endian.
      * TODO: This manual swap is of course suboptimal.
      */
-    for (i = 0; i < frame_size; i += 4)
-        AV_WB32(pkt->data + i, avio_rl32(pb));
+    for (i = 0; i < frame_size; i += 4) {
+        uint32_t val = avio_rl32(pb);
+        AV_WB32(pkt->data + i, val);
+    }
 
     pkt->stream_index = video->stream_index;