diff mbox series

[FFmpeg-devel,25/39] avcodec/pnmdec, pnm_parser: Improve const-correctness

Message ID DB6PR0101MB221479C5069498E13FFE1EFA8F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 22ca2ef018096ce6019070e2067128dbd2f8d1fc
Headers show
Series [FFmpeg-devel,01/39] avcodec/hevcdsp: Constify src pointers | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 fail Make failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 26, 2022, 10:08 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/pnm.c        | 2 +-
 libavcodec/pnm.h        | 6 +++---
 libavcodec/pnm_parser.c | 8 ++++----
 libavcodec/pnmdec.c     | 4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 605a529622..aabc788684 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -38,7 +38,7 @@  static void pnm_get(PNMContext *sc, char *str, int buf_size)
 {
     char *s;
     int c;
-    uint8_t *bs  = sc->bytestream;
+    const uint8_t *bs  = sc->bytestream;
     const uint8_t *end = sc->bytestream_end;
 
     /* skip spaces and comments */
diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h
index f109d16239..5bf2eaa4d9 100644
--- a/libavcodec/pnm.h
+++ b/libavcodec/pnm.h
@@ -25,9 +25,9 @@ 
 #include "avcodec.h"
 
 typedef struct PNMContext {
-    uint8_t *bytestream;
-    uint8_t *bytestream_start;
-    uint8_t *bytestream_end;
+    const uint8_t *bytestream;
+    const uint8_t *bytestream_start;
+    const uint8_t *bytestream_end;
     int maxval;                 ///< maximum value of a pixel
     int type;
     int endian;
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 6607ac7e7f..74f918a94b 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -65,8 +65,8 @@  retry:
         pnmctx.bytestream_end   = pc->buffer + pc->index;
     } else {
         pnmctx.bytestream_start =
-        pnmctx.bytestream       = (uint8_t *) buf + skip; /* casts avoid warnings */
-        pnmctx.bytestream_end   = (uint8_t *) buf + buf_size - skip;
+        pnmctx.bytestream       = buf + skip;
+        pnmctx.bytestream_end   = buf + buf_size - skip;
     }
     if (ff_pnm_decode_header(avctx, &pnmctx) < 0) {
         if (pnmctx.bytestream < pnmctx.bytestream_end) {
@@ -81,9 +81,9 @@  retry:
             goto retry;
         }
     } else if (pnmctx.type < 4) {
-              uint8_t *bs  = pnmctx.bytestream;
+        const uint8_t *bs   = pnmctx.bytestream;
         const uint8_t *end = pnmctx.bytestream_end;
-        uint8_t *sync      = bs;
+        const uint8_t *sync = bs;
 
         if (pc->index) {
             av_assert0(pnmpc->ascii_scan <= end - bs);
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index bb2ce53496..7cf9886ce7 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -52,8 +52,8 @@  static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
     float scale;
 
     s->bytestream_start =
-    s->bytestream       = (uint8_t *)buf;
-    s->bytestream_end   = (uint8_t *)buf + buf_size;
+    s->bytestream       = buf;
+    s->bytestream_end   = buf + buf_size;
 
     if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
         return ret;