On Sun, Jan 24, 2010 at 10:14 PM, Manu Abraham <abraham.m...@gmail.com> wrote:
> Hi Klaas,
>
> On Sun, Jan 24, 2010 at 2:58 PM, klaas de waal <klaas.de.w...@gmail.com> 
> wrote:
>> The czap utility (dvb-apps/util/szap/czap.c) cannot scan the channel
>> configuration file when compiled on Fedora 12 with gcc-4.4.2.
>>
>> The czap output is:
>>
>> [kl...@myth2 szap]$ ./czap -c ~/.czap/ziggo-channels.conf Cartoon
>> using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
>> reading channels from file '/local/klaas/.czap/ziggo-channels.conf'
>>  1 Cartoon:356000000:INVERSION_AUTO:6875000:FEC_NONE:QAM_64:1660:1621
>> ERROR: cannot parse service data
>>
>> Problem is tha the "sscanf" function uses the "%a[^:]" format
>> specifier. According to "man sscanf" you need to define _GNU_SOURCE if
>> you want this to work because it is a gnu-only extension.
>> Adding a first line "#define _GNU_SOURCE" to czap.c and recompiling
>> solves the problem.
>>
>> The czap output is now:
>>
>> [kl...@myth2 szap]$ ./czap -c ~/.czap/ziggo-channels.conf Cartoon
>> using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
>> reading channels from file '/local/klaas/.czap/ziggo-channels.conf'
>>  1 Cartoon:356000000:INVERSION_AUTO:6875000:FEC_NONE:QAM_64:1660:1621
>>  1 Cartoon: f 356000000, s 6875000, i 2, fec 0, qam 3, v 0x67c, a 0x655
>> status 00 | signal 0000 | snr b7b7 | ber 000fffff | unc 00000098 |
>> status 1f | signal d5d5 | snr f3f3 | ber 000006c0 | unc 0000009b | 
>> FE_HAS_LOCK
>> status 1f | signal d5d5 | snr f4f4 | ber 00000000 | unc 00000000 | 
>> FE_HAS_LOCK
>>
>> This is done on a Linux 2.6.32.2 kernel with a TT C-1501 DVB-C card.
>>
>> Signed-off-by: Klaas de Waal <klaas.de.w...@gmail.com>
>>
>> -------------------------------------------------------------------------------------------
>>
>> diff -r 61b72047a995 util/szap/czap.c
>> --- a/util/szap/czap.c  Sun Jan 17 17:03:27 2010 +0100
>> +++ b/util/szap/czap.c  Sun Jan 24 11:40:43 2010 +0100
>> @@ -1,3 +1,4 @@
>> +#define _GNU_SOURCE
>>  #include <sys/types.h>
>>  #include <sys/stat.h>
>>  #include <sys/ioctl.h>
>>
>
> There seems to be other instances where _GNU_SOURCE needs to be
> defined, from a quick look. Care to send a patch against the entire
> dvb-apps tree ?
>
> Regards,
> Manu
>

Hi Manu,

I did have a reasonably good look at the code and at the compilation
log created with "-pedantic" added to the CFLAGS but although there
are a lot of GNU extensions used I think they will compile correct. I
do not think that the _GNU_SOURCE definitions need to be added
anywhere.

Having said that, I am not even happy anymore with the _GNU_SOURCE in
czap.c although it does solve the problem.

I have now added "std=gnu99 -Wformat" to the default CFLAGS in
Make.rules. This flags the use of the "a" format specifier as used in
the sscanf statement in czap.c as an error, although it works when
_GNU_SOURCE is defined.
I have now modified the czap.c to use the "m" format specifier which
does just what the 'a" used to do.
This works OK, it does not give compilation messages and it does not
require _GNU_SOURCE so I think it is a better solution. Hope you like
it.

Regards,
Klaas.

Signed-off-by: Klaas de Waal <klaas.de.w...@gmail.com>

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

diff -r 61b72047a995 Make.rules
--- a/Make.rules        Sun Jan 17 17:03:27 2010 +0100
+++ b/Make.rules        Mon Jan 25 22:27:05 2010 +0100
@@ -1,6 +1,7 @@
 # build rules for linuxtv.org dvb-apps

-CFLAGS ?= -g -Wall -W -Wshadow -Wpointer-arith -Wstrict-prototypes
+CFLAGS ?= -g -Wall -W -Wshadow -Wpointer-arith -Wstrict-prototypes \
+-std=gnu99 -Wformat

 ifneq ($(lib_name),)

diff -r 61b72047a995 util/szap/czap.c
--- a/util/szap/czap.c  Sun Jan 17 17:03:27 2010 +0100
+++ b/util/szap/czap.c  Mon Jan 25 22:27:05 2010 +0100
@@ -141,7 +141,7 @@
        }
        printf("%3d %s", chan_no, chan);

-       if ((sscanf(chan, "%a[^:]:%d:%a[^:]:%d:%a[^:]:%a[^:]:%d:%d\n",
+       if ((sscanf(chan, "%m[^:]:%d:%m[^:]:%d:%m[^:]:%m[^:]:%d:%d\n",
                                &name, &frontend->frequency,
                                &inv, &frontend->u.qam.symbol_rate,
                                &fec, &mod, vpid, apid) != 8)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to