perror() is only used twice in the code, everything else uses fprintf to stderr. diff --git a/src/dvd_input.c b/src/dvd_input.c index d7e2252..7cb3594 100644 --- a/src/dvd_input.c +++ b/src/dvd_input.c @@ -172,7 +172,7 @@ static dvd_input_t file_open(const char *target) dev->fd = open(target, O_RDONLY | O_BINARY); #endif if(dev->fd < 0) { - perror("libdvdread: Could not open input"); + fprintf(stderr, "libdvdread: Could not open input\n"); free(dev); return NULL; } diff --git a/src/dvd_reader.c b/src/dvd_reader.c index 00a3398..63012d4 100644 --- a/src/dvd_reader.c +++ b/src/dvd_reader.c @@ -390,7 +390,6 @@ dvd_reader_t *DVDOpen( const char *ppath ) /* If we can't stat the file, give up */ fprintf( stderr, "libdvdread: Can't stat %s\n", path ); - perror(""); goto DVDOpen_error; }
Hi, On Tue, Apr 15, 2014 at 11:34:03AM -0600, Steve Dibb wrote:
perror() is only used twice in the code, everything else uses fprintf to stderr.
perror() gives additional information, e.g. 'permission denied' or 'no such file or directory'. This might be helpful. Why do you want to remove perror()? Thanks, Erik -- Memory, of course, is never true. -- Ernest Hemingway
On Wed 16 Apr 2014 09:51:41 Erik Auerswald wrote:
On Tue, Apr 15, 2014 at 11:34:03AM -0600, Steve Dibb wrote:
perror() is only used twice in the code, everything else uses fprintf to stderr.
perror() gives additional information, e.g. 'permission denied' or 'no such file or directory'. This might be helpful.
Why do you want to remove perror()?
right ... either replace it with equivalent code, or leave it be fprintf(stderr, "open(%s) failed: %s\n", path, strerror(errno)); -mike
On Tue, Apr 15, 2014 at 7:34 PM, Steve Dibb <beandog@gentoo.org> wrote:
perror() is only used twice in the code, everything else uses fprintf to stderr.
Hijacking the thread a bit here but would we not want to replace all printf(...); and fprintf(stderr, ...) with some kind of log callback instead? I've done that in an old fork I've got of the libdvd libraries and now that the project seem to have spurred to life a bit again I'm thinking of trying to upstream those kind of changes.
On 16 Apr, Andreas Öman wrote :
Hijacking the thread a bit here but would we not want to replace all printf(...); and fprintf(stderr, ...) with some kind of log callback instead?
YES. But please make it thread-safe, not like the famous libavcodec stuff. With my kindest regards, -- Jean-Baptiste Kempf http://www.jbkempf.com/ - +33 672 704 734 Sent from my Electronic Device
On Thu, Apr 17, 2014 at 3:22 PM, Jean-Baptiste Kempf <jb@videolan.org>wrote:
But please make it thread-safe, not like the famous libavcodec stuff.
I was thinking about doing something very simple, like a global function pointer. void (*libdvdnav_log)(void *opaque, const char *fmt, ...); And then just have a default implementation that prints to stderr. Then if the app uses multiple threads for DVD playback it will need to sort out locking by itself. I also suggest dropping all \n from the log messages. This would make the default log-to-stderr either a bit racy (it would have to first print the log message and then fprintf(stderr, "\n"); or it would need to append a \n to the format string before passing it into vfnprintf() Thoughts welcome.
participants (5)
-
Andreas Öman -
Erik Auerswald -
Jean-Baptiste Kempf -
Mike Frysinger -
Steve Dibb