On Fri, Nov 30, 2012 at 11:00 AM, Dieter Bloms <v...@bloms.de> wrote:
> > --snip-- > g++ -g -O3 -Wall -Werror=overloaded-virtual -Wno-parentheses -c > -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE > -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE > -DVDR_USER=\"root\" -DLIRC_DEVICE=\"/var/run/lirc/lircd\" -D_GNU_SOURCE > -DVIDEODIR=\"/remote/vdr/video\" -DCONFDIR=\"/etc/vdr/config\" > -DCACHEDIR=\"\" -DRESDIR=\"\" > -DPLUGINDIR=\"/usr/src/vdr-1.7.32/PLUGINS/lib\" > -DLOCDIR=\"/usr/share/vdr/locale\" -I/usr/include/freetype2 > -I/usr/src/v4l-dvb/linux/include epg.c > epg.c: In member function 'bool tComponent::FromString(const char*)': > epg.c:37:3: warning: format '%a' expects argument of type 'double', but > argument 6 has type 'char*' [-Wformat] > --snip-- > > And after start in the logfile > > --snip-- > Nov 30 09:48:05 vdrservernew local1.err vdr: [4094] dbloms: "1" "01" " > deu" "0x8.799b08p-1052" > --snip-- > > I think %a in my esyslog call isn't correct, but it is used this way > with the sscanf call and when I changed it with %s I don't see any log > entry. > > So how should the esyslog call look like ? > > %a to print a char* is not right. char* is interpreted as double (see the compiler warning) . If you want to print the pointer 'description', then use %p. The following code crashes on my box too. I dont know why. $ ./a.out errno: 0 n=4 Stream:1 Type:1 lang:'deu' desc addr:'0x40800000' Segmentation fault $ In gdb: Program received signal SIGSEGV, Segmentation fault. 0x0016e50b in _IO_vfprintf_internal (s=0x2844e0, format=0x8048711 "desc:'%s'\n", ap=0xbffff3f4 "") at vfprintf.c:1614 1614 vfprintf.c: No such file or directory. in vfprintf.c (gdb) bt #0 0x0016e50b in _IO_vfprintf_internal (s=0x2844e0, format=0x8048711 "desc:'%s'\n", ap=0xbffff3f4 "") at vfprintf.c:1614 #1 0x00175160 in __printf (format=0x8048711 "desc:'%s'\n") at printf.c:35 #2 0x080485aa in FromString (s=0x804871c "1 01 deu 4:3") at fromstring.c:14 #3 0x080485ee in main (argc=1, argv=0xbffff514) at fromstring.c:22 --- snip --- #include <stdio.h> #include <errno.h> void FromString(const char *s) { unsigned int Stream, Type; char language[8] = {0}; char* description=NULL; int n = sscanf(s, "%X %02X %7s %a[^\n]", &Stream, &Type, language, &description); // 7 = MAXLANGCODE2 - 1 printf("errno: %d\n", errno); printf("n=%d\n", n); printf("Stream:%u Type:%u lang:'%s'\n", Stream, Type, language); printf("desc addr:'%p'\n", description); printf("desc:'%s'\n", description); // XXX crashes here } int main(int argc, char* argv[]) { if (argc == 2) FromString((const char*)argv[1]); else FromString("1 01 deu 4:3"); return 0; } ----- snip -----
_______________________________________________ vdr mailing list vdr@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr