[1/2] Revert "Don't use expressions with side effects in macro parameters"

Message ID 1470132746-31487-1-git-send-email-martin@martin.st
State Committed
Commit 9806b9ab5c7fb2ac5efd8ffa8713fea0c5fd218d
Headers show

Commit Message

Martin Storsjö Aug. 2, 2016, 10:12 a.m.
This reverts commit 25bacd0a0c32ae682e6f411b1ac9020aeaabca72.

Since 230b1c070, the bytewise AV_W*() macros only expand their
argument once, so revert to the more readable version of these.
---
 libavcodec/dxv.c  | 18 ++++++------------
 libavformat/xmv.c |  6 ++----
 2 files changed, 8 insertions(+), 16 deletions(-)

Comments

Diego Biurrun Aug. 2, 2016, 10:22 a.m. | #1
On Tue, Aug 02, 2016 at 01:12:25PM +0300, Martin Storsjö wrote:
> This reverts commit 25bacd0a0c32ae682e6f411b1ac9020aeaabca72.
> 
> Since 230b1c070, the bytewise AV_W*() macros only expand their
> argument once, so revert to the more readable version of these.
> ---
>  libavcodec/dxv.c  | 18 ++++++------------
>  libavformat/xmv.c |  6 ++----
>  2 files changed, 8 insertions(+), 16 deletions(-)

OK

Diego

Patch

diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index 39b297a..99327df 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -121,10 +121,8 @@  static int dxv_decompress_dxt1(AVCodecContext *avctx)
     int pos = 2;
 
     /* Copy the first two elements */
-    value = bytestream2_get_le32(gbc);
-    AV_WL32(ctx->tex_data, value);
-    value = bytestream2_get_le32(gbc);
-    AV_WL32(ctx->tex_data + 4, value);
+    AV_WL32(ctx->tex_data, bytestream2_get_le32(gbc));
+    AV_WL32(ctx->tex_data + 4, bytestream2_get_le32(gbc));
 
     /* Process input until the whole texture has been filled */
     while (pos + 2 <= ctx->tex_size / 4) {
@@ -174,14 +172,10 @@  static int dxv_decompress_dxt5(AVCodecContext *avctx)
     int probe, check;
 
     /* Copy the first four elements */
-    value = bytestream2_get_le32(gbc);
-    AV_WL32(ctx->tex_data +  0, value);
-    value = bytestream2_get_le32(gbc);
-    AV_WL32(ctx->tex_data +  4, value);
-    value = bytestream2_get_le32(gbc);
-    AV_WL32(ctx->tex_data +  8, value);
-    value = bytestream2_get_le32(gbc);
-    AV_WL32(ctx->tex_data + 12, value);
+    AV_WL32(ctx->tex_data +  0, bytestream2_get_le32(gbc));
+    AV_WL32(ctx->tex_data +  4, bytestream2_get_le32(gbc));
+    AV_WL32(ctx->tex_data +  8, bytestream2_get_le32(gbc));
+    AV_WL32(ctx->tex_data + 12, bytestream2_get_le32(gbc));
 
     /* Process input until the whole texture has been filled */
     while (pos + 2 <= ctx->tex_size / 4) {
diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index fa39156..b2112b0 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -512,10 +512,8 @@  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) {
-        uint32_t val = avio_rl32(pb);
-        AV_WB32(pkt->data + i, val);
-    }
+    for (i = 0; i < frame_size; i += 4)
+        AV_WB32(pkt->data + i, avio_rl32(pb));
 
     pkt->stream_index = video->stream_index;