[FFmpeg-devel] [PATCH 2/5] all: fix incorrect usage of %p format specifier

Ganesh Ajjanagadde gajjanag at mit.edu
Sat Oct 24 15:35:48 CEST 2015


Hi all,

Apologies for the copy/pasted patch, but can't send via send-email.
Copy pasted for review below, attached also for a non-clobbered
version.

----------------------------------------------------------------------------------

>From 99cd052b614553757efa1954bf8bf4dd3caf66d0 Mon Sep 17 00:00:00 2001
From: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
Date: Fri, 23 Oct 2015 11:59:40 -0400
Subject: [PATCH 2/5] all: fix incorrect usage of %p format specifier

ISO C %p format specifier applies to void * data pointers. This casts
relevant pointers to void * in order to be strictly correct C.

Found by -Wpedantic on clang 3.7 (in particular -Wformat-pedantic).

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 libavcodec/alsdec.c          | 8 ++++----
 libavcodec/h264_refs.c       | 6 +++---
 libavcodec/libopencore-amr.c | 2 +-
 libavcodec/mjpegdec.c        | 2 +-
 libavcodec/mpegpicture.c     | 2 +-
 libavcodec/mpegvideo.c       | 8 ++++----
 libavcodec/options.c         | 2 +-
 libavcodec/pthread_frame.c   | 6 +++---
 libavcodec/utils.c           | 4 ++--
 libavcodec/vaapi_h264.c      | 2 +-
 libavcodec/vaapi_hevc.c      | 2 +-
 libavcodec/vaapi_mpeg2.c     | 2 +-
 libavcodec/vaapi_mpeg4.c     | 2 +-
 libavcodec/vaapi_vc1.c       | 2 +-
 libavcodec/vorbisdec.c       | 2 +-
 libavfilter/avfilter.c       | 6 +++---
 libavformat/asfdec_f.c       | 2 +-
 libavformat/rtpdec_h264.c    | 2 +-
 libavformat/utils.c          | 2 +-
 libswscale/swscale.c         | 8 ++++----
 20 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index ebd364e..19bdbbd 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1308,8 +1308,8 @@ static int
revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
                 FFMAX(end   + 1,   end + 1 + t) > ctx->raw_buffer +
channels * channel_size - master) {
                 av_log(ctx->avctx, AV_LOG_ERROR,
                        "sample pointer range [%p, %p] not contained
in raw_buffer [%p, %p].\n",
-                       master + FFMIN(begin - 1, begin - 1 + t),
master + FFMAX(end + 1,   end + 1 + t),
-                       ctx->raw_buffer, ctx->raw_buffer + channels *
channel_size);
+                       (void *)(master + FFMIN(begin - 1, begin - 1 +
t)), (void *)(master + FFMAX(end + 1, end + 1 + t)),
+                       (void *)ctx->raw_buffer, (void
*)(ctx->raw_buffer + channels * channel_size));
                 return AVERROR_INVALIDDATA;
             }

@@ -1330,8 +1330,8 @@ static int
revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
                 end   + 1 > ctx->raw_buffer + channels * channel_size
- master) {
                 av_log(ctx->avctx, AV_LOG_ERROR,
                        "sample pointer range [%p, %p] not contained
in raw_buffer [%p, %p].\n",
-                       master + begin - 1, master + end + 1,
-                       ctx->raw_buffer, ctx->raw_buffer + channels *
channel_size);
+                       (void *)(master + begin - 1), (void *)(master
+ end + 1),
+                       (void *)(ctx->raw_buffer), (void
*)(ctx->raw_buffer + channels * channel_size));
                 return AVERROR_INVALIDDATA;
             }

diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 619f2ed..da6e7fd 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -437,7 +437,7 @@ static H264Picture *find_short(H264Context *h, int
frame_num, int *idx)
     for (i = 0; i < h->short_ref_count; i++) {
         H264Picture *pic = h->short_ref[i];
         if (h->avctx->debug & FF_DEBUG_MMCO)
-            av_log(h->avctx, AV_LOG_DEBUG, "%d %d %p\n", i,
pic->frame_num, pic);
+            av_log(h->avctx, AV_LOG_DEBUG, "%d %d %p\n", i,
pic->frame_num, (void *)pic);
         if (pic->frame_num == frame_num) {
             *idx = i;
             return pic;
@@ -543,7 +543,7 @@ static void print_short_term(H264Context *h)
         for (i = 0; i < h->short_ref_count; i++) {
             H264Picture *pic = h->short_ref[i];
             av_log(h->avctx, AV_LOG_DEBUG, "%"PRIu32" fn:%d poc:%d %p\n",
-                   i, pic->frame_num, pic->poc, pic->f->data[0]);
+                   i, pic->frame_num, pic->poc, (void *)pic->f->data[0]);
         }
     }
 }
@@ -560,7 +560,7 @@ static void print_long_term(H264Context *h)
             H264Picture *pic = h->long_ref[i];
             if (pic) {
                 av_log(h->avctx, AV_LOG_DEBUG, "%"PRIu32" fn:%d poc:%d %p\n",
-                       i, pic->frame_num, pic->poc, pic->f->data[0]);
+                       i, pic->frame_num, pic->poc, (void *)pic->f->data[0]);
             }
         }
     }
diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c
index f0e3426..850ad94 100644
--- a/libavcodec/libopencore-amr.c
+++ b/libavcodec/libopencore-amr.c
@@ -100,7 +100,7 @@ static int amr_nb_decode_frame(AVCodecContext
*avctx, void *data,
     int packet_size, ret;

     ff_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n",
-            buf, buf_size, avctx->frame_number);
+            (void *)buf, buf_size, avctx->frame_number);

     /* get output buffer */
     frame->nb_samples = 160;
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 1a86b7b..36812aa 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -652,7 +652,7 @@ static inline int
mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
     if (code < 0 || code > 16) {
         av_log(s->avctx, AV_LOG_WARNING,
                "mjpeg_decode_dc: bad vlc: %d:%d (%p)\n",
-               0, dc_index, &s->vlcs[0][dc_index]);
+               0, dc_index, (void *)&s->vlcs[0][dc_index]);
         return 0xfffff;
     }

diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 16b8f52..76b8dd8 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -123,7 +123,7 @@ static int alloc_frame_buffer(AVCodecContext
*avctx,  Picture *pic,

     if (r < 0 || !pic->f->buf[0]) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
-               r, pic->f->data[0]);
+               r, (void *)pic->f->data[0]);
         return -1;
     }

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 96634ec..7f5e617 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1274,10 +1274,10 @@ int ff_mpv_frame_start(MpegEncContext *s,
AVCodecContext *avctx)
             s->next_picture_ptr = s->current_picture_ptr;
     }
     ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
-            s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,
-            s->last_picture_ptr    ? s->last_picture_ptr->f->data[0]    : NULL,
-            s->next_picture_ptr    ? s->next_picture_ptr->f->data[0]    : NULL,
-            s->current_picture_ptr ? s->current_picture_ptr->f->data[0] : NULL,
+            (void *)s->last_picture_ptr, (void *)s->next_picture_ptr,
(void *)s->current_picture_ptr,
+            s->last_picture_ptr    ? (void
*)s->last_picture_ptr->f->data[0]    : NULL,
+            s->next_picture_ptr    ? (void
*)s->next_picture_ptr->f->data[0]    : NULL,
+            s->current_picture_ptr ? (void
*)s->current_picture_ptr->f->data[0] : NULL,
             s->pict_type, s->droppable);

     if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) &&
diff --git a/libavcodec/options.c b/libavcodec/options.c
index ea2563b..9b4f3af 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -187,7 +187,7 @@ int avcodec_copy_context(AVCodecContext *dest,
const AVCodecContext *src)
     if (avcodec_is_open(dest)) { // check that the dest context is
uninitialized
         av_log(dest, AV_LOG_ERROR,
                "Tried to copy AVCodecContext %p into already-initialized %p\n",
-               src, dest);
+               (void *)src, (void *)dest);
         return AVERROR(EINVAL);
     }

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 7651211..52161aa 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -486,7 +486,7 @@ void ff_thread_report_progress(ThreadFrame *f, int
n, int field)
     p = f->owner->internal->thread_ctx;

     if (f->owner->debug&FF_DEBUG_THREADS)
-        av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n",
progress, n, field);
+        av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n",
(void *)progress, n, field);

     pthread_mutex_lock(&p->progress_mutex);
     progress[field] = n;
@@ -504,7 +504,7 @@ void ff_thread_await_progress(ThreadFrame *f, int
n, int field)
     p = f->owner->internal->thread_ctx;

     if (f->owner->debug&FF_DEBUG_THREADS)
-        av_log(f->owner, AV_LOG_DEBUG, "thread awaiting %d field %d
from %p\n", n, field, progress);
+        av_log(f->owner, AV_LOG_DEBUG, "thread awaiting %d field %d
from %p\n", n, field, (void *)progress);

     pthread_mutex_lock(&p->progress_mutex);
     while (progress[field] < n)
@@ -868,7 +868,7 @@ void ff_thread_release_buffer(AVCodecContext
*avctx, ThreadFrame *f)
         return;

     if (avctx->debug & FF_DEBUG_BUFFERS)
-        av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on
pic %p\n", f);
+        av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on
pic %p\n", (void *)f);

     av_buffer_unref(&f->progress);
     f->owner    = NULL;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 83a2078..b78422e 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -642,7 +642,7 @@ static int audio_get_buffer(AVCodecContext *avctx,
AVFrame *frame)
     }

     if (avctx->debug & FF_DEBUG_BUFFERS)
-        av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on
frame %p", frame);
+        av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on
frame %p", (void *)frame);

     return 0;
 fail:
@@ -680,7 +680,7 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
         avpriv_set_systematic_pal2((uint32_t *)pic->data[1], s->pix_fmt);

     if (s->debug & FF_DEBUG_BUFFERS)
-        av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p\n", pic);
+        av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic
%p\n", (void *)pic);

     return 0;
 fail:
diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index ded2cb3..fc427a6 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -324,7 +324,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
     VASliceParameterBufferH264 *slice_param;

     ff_dlog(avctx, "vaapi_h264_decode_slice(): buffer %p, size %d\n",
-            buffer, size);
+            (void *)buffer, size);

     /* Fill in VASliceParameterBufferH264. */
     slice_param = (VASliceParameterBufferH264
*)ff_vaapi_alloc_slice(vactx, buffer, size);
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 62f783e..d63ac76 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -407,7 +407,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
     if (sh->slice_type == I_SLICE)
         nb_list = 0;

-    ff_dlog(avctx, "vaapi_hevc_decode_slice(): buffer %p, size %d\n",
buffer, size);
+    ff_dlog(avctx, "vaapi_hevc_decode_slice(): buffer %p, size %d\n",
(void *)buffer, size);

     /* Fill in VASliceParameterBufferH264. */
     slice_param = (VASliceParameterBufferHEVC
*)ff_vaapi_alloc_slice(vactx, buffer, size);
diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
index 518fec0..c6cda3b 100644
--- a/libavcodec/vaapi_mpeg2.c
+++ b/libavcodec/vaapi_mpeg2.c
@@ -109,7 +109,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext
*avctx, const uint8_t *buffer
     GetBitContext gb;
     uint32_t quantiser_scale_code, intra_slice_flag, macroblock_offset;

-    ff_dlog(avctx, "vaapi_mpeg2_decode_slice(): buffer %p, size
%d\n", buffer, size);
+    ff_dlog(avctx, "vaapi_mpeg2_decode_slice(): buffer %p, size
%d\n", (void *)buffer, size);

     /* Determine macroblock_offset */
     init_get_bits(&gb, buffer, 8 * size);
diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
index b5b946d..a678a3d 100644
--- a/libavcodec/vaapi_mpeg4.c
+++ b/libavcodec/vaapi_mpeg4.c
@@ -125,7 +125,7 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext
*avctx, const uint8_t *buffer
     FFVAContext * const vactx = ff_vaapi_get_context(avctx);
     VASliceParameterBufferMPEG4 *slice_param;

-    ff_dlog(avctx, "vaapi_mpeg4_decode_slice(): buffer %p, size
%d\n", buffer, size);
+    ff_dlog(avctx, "vaapi_mpeg4_decode_slice(): buffer %p, size
%d\n", (void *)buffer, size);

     /* Fill in VASliceParameterBufferMPEG4 */
     slice_param = (VASliceParameterBufferMPEG4
*)ff_vaapi_alloc_slice(vactx, buffer, size);
diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c
index 5ded5db..38a387e 100644
--- a/libavcodec/vaapi_vc1.c
+++ b/libavcodec/vaapi_vc1.c
@@ -318,7 +318,7 @@ static int vaapi_vc1_decode_slice(AVCodecContext
*avctx, const uint8_t *buffer,
     FFVAContext * const vactx = ff_vaapi_get_context(avctx);
     VASliceParameterBufferVC1 *slice_param;

-    ff_dlog(avctx, "vaapi_vc1_decode_slice(): buffer %p, size %d\n",
buffer, size);
+    ff_dlog(avctx, "vaapi_vc1_decode_slice(): buffer %p, size %d\n",
(void *)buffer, size);

     /* Current bit buffer is beyond any marker for VC-1, so skip it */
     if (avctx->codec_id == AV_CODEC_ID_VC1 && IS_MARKER(AV_RB32(buffer))) {
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index f773afa..3075223 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -663,7 +663,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
             ff_dlog(NULL, "floor0 number of books: %u\n",
                     floor_setup->data.t0.num_books);
             ff_dlog(NULL, "floor0 book list pointer: %p\n",
-                    floor_setup->data.t0.book_list);
+                    (void *)floor_setup->data.t0.book_list);
             {
                 int idx;
                 for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) {
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 8b1b7d2..841373a 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -47,7 +47,7 @@ void ff_tlog_ref(void *ctx, AVFrame *ref, int end)
     av_unused char buf[16];
     ff_tlog(ctx,
             "ref[%p buf:%p data:%p linesize[%d, %d, %d, %d]
pts:%"PRId64" pos:%"PRId64,
-            ref, ref->buf, ref->data[0],
+            (void *)ref, (void *)ref->buf, (void *)ref->data[0],
             ref->linesize[0], ref->linesize[1], ref->linesize[2],
ref->linesize[3],
             ref->pts, av_frame_get_pkt_pos(ref));

@@ -321,7 +321,7 @@ void ff_tlog_link(void *ctx, AVFilterLink *link, int end)
     if (link->type == AVMEDIA_TYPE_VIDEO) {
         ff_tlog(ctx,
                 "link[%p s:%dx%d fmt:%s %s->%s]%s",
-                link, link->w, link->h,
+                (void *)link, link->w, link->h,
                 av_get_pix_fmt_name(link->format),
                 link->src ? link->src->filter->name : "",
                 link->dst ? link->dst->filter->name : "",
@@ -332,7 +332,7 @@ void ff_tlog_link(void *ctx, AVFilterLink *link, int end)

         ff_tlog(ctx,
                 "link[%p r:%d cl:%s fmt:%s %s->%s]%s",
-                link, (int)link->sample_rate, buf,
+                (void *)link, (int)link->sample_rate, buf,
                 av_get_sample_fmt_name(link->format),
                 link->src ? link->src->filter->name : "",
                 link->dst ? link->dst->filter->name : "",
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 7c31cfa..538c965 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -1327,7 +1327,7 @@ static int asf_parse_packet(AVFormatContext *s,
AVIOContext *pb, AVPacket *pkt)
         /* read data */
         av_log(asf, AV_LOG_TRACE, "READ PACKET s:%d  os:%d  o:%d,%d
l:%d   DATA:%p\n",
                 s->packet_size, asf_st->pkt.size, asf->packet_frag_offset,
-                asf_st->frag_offset, asf->packet_frag_size, asf_st->pkt.data);
+                asf_st->frag_offset, asf->packet_frag_size, (void
*)asf_st->pkt.data);
         asf->packet_size_left -= asf->packet_frag_size;
         if (asf->packet_size_left < 0)
             continue;
diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c
index b399be4..a556fda 100644
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -171,7 +171,7 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
         ret = ff_h264_parse_sprop_parameter_sets(s, &codec->extradata,

&codec->extradata_size, value);
         av_log(s, AV_LOG_DEBUG, "Extradata set to %p (size: %d)\n",
-               codec->extradata, codec->extradata_size);
+               (void *)codec->extradata, codec->extradata_size);
         return ret;
     }
     return 0;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 689473e..9a25b77 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1096,7 +1096,7 @@ static void compute_pkt_fields(AVFormatContext
*s, AVStream *st,
         av_log(s, AV_LOG_TRACE,
             "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p
duration:%"PRId64" delay:%d onein_oneout:%d\n",
             presentation_delayed, av_ts2str(pkt->pts),
av_ts2str(pkt->dts), av_ts2str(st->cur_dts),
-            pkt->stream_index, pc, pkt->duration, delay, onein_oneout);
+            pkt->stream_index, (void *)pc, pkt->duration, delay, onein_oneout);

     /* Interpolate PTS and DTS if they are not present. We skip H264
      * currently because delay and has_b_frames are not reliably set. */
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 1769348..2567390 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -421,10 +421,10 @@ static int swscale(SwsContext *c, const uint8_t *src[],
     srcStride[2] <<= c->vChrDrop;

     DEBUG_BUFFERS("swscale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d]
%p[%d] %p[%d] %p[%d]\n",
-                  src[0], srcStride[0], src[1], srcStride[1],
-                  src[2], srcStride[2], src[3], srcStride[3],
-                  dst[0], dstStride[0], dst[1], dstStride[1],
-                  dst[2], dstStride[2], dst[3], dstStride[3]);
+                  (void *)src[0], srcStride[0], (void *)src[1], srcStride[1],
+                  (void *)src[2], srcStride[2], (void *)src[3], srcStride[3],
+                  (void *)dst[0], dstStride[0], (void *)dst[1], dstStride[1],
+                  (void *)dst[2], dstStride[2], (void *)dst[3], dstStride[3]);
     DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
                   srcSliceY, srcSliceH, dstY, dstH);
     DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize:
%d vChrBufSize: %d\n",
-- 
2.6.2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-all-fix-incorrect-usage-of-p-format-specifier.patch
Type: text/x-diff
Size: 18603 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151024/3b4201f7/attachment.patch>


More information about the ffmpeg-devel mailing list