[DVDnav-discuss] [PATCH] libdvdread/src/ifo_read.c: Format fraction as float and update error message

Paul Menzel paulepanter at users.sourceforge.net
Mon Nov 18 17:25:29 CET 2013


Date: Mon, 18 Nov 2013 16:54:51 +0100

GCC 4.8.2 and Clang 3.4 both warn about a format mismatch.

        libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../src -mno-ms-bitfields -O3 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -MT ifo_read.lo -MD -MP -MF .deps/ifo_read.Tpo -c ifo_read.c  -fPIC -DPIC -o .libs/ifo_read.o
        ifo_read.c: In function 'ifoRead_TT_SRPT':
        ifo_read.c:1078:13: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'unsigned int' [-Wformat=]
                     info_length/sizeof(title_info_t),tt_srpt->nr_of_srpts);

        libtool: compile:  clang -DHAVE_CONFIG_H -I. -I.. -I.. -I../src -O3 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -MT ifo_read.lo -MD -MP -MF .deps/ifo_read.Tpo -c ifo_read.c  -fPIC -DPIC -o .libs/ifo_read.o
        ifo_read.c:1078:13: warning: format specifies type 'long' but the argument has type 'unsigned int' [-Wformat]
                    info_length/sizeof(title_info_t),tt_srpt->nr_of_srpts);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix this by actually displaying the float value and by updating the
error message.
---
 libdvdread/src/ifo_read.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libdvdread/src/ifo_read.c b/libdvdread/src/ifo_read.c
index 36545ce..5640e0a 100644
--- a/libdvdread/src/ifo_read.c
+++ b/libdvdread/src/ifo_read.c
@@ -1074,8 +1074,8 @@ int ifoRead_TT_SRPT(ifo_handle_t *ifofile) {
   }
 
   if(tt_srpt->nr_of_srpts>info_length/sizeof(title_info_t)){
-    fprintf(stderr,"libdvdread: data mismatch: info_length (%ld)!= nr_of_srpts (%d). Truncating.\n",
-            info_length/sizeof(title_info_t),tt_srpt->nr_of_srpts);
+    fprintf(stderr,"libdvdread: data mismatch: info_length/sizeof(title_info_t) (%f)!= nr_of_srpts (%d). Truncating.\n",
+            info_length * 1.0/sizeof(title_info_t),tt_srpt->nr_of_srpts);
     tt_srpt->nr_of_srpts=info_length/sizeof(title_info_t);
   }
 
-- 
1.8.4.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mplayerhq.hu/pipermail/dvdnav-discuss/attachments/20131118/3bc66c00/attachment.asc>


More information about the DVDnav-discuss mailing list