[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libcdio-devel] [PATCH] Use cdio logging facility for all warnings
From: |
Rocky Bernstein |
Subject: |
Re: [Libcdio-devel] [PATCH] Use cdio logging facility for all warnings |
Date: |
Tue, 24 Jan 2012 20:18:25 -0500 |
On Tue, Jan 24, 2012 at 1:57 PM, Pete Batard <address@hidden> wrote:
> For some reason, udf_fs.c doesn't use the cdio logging facility whereas
> udf_fs.c does.
An inadvertent omission on my part. Thanks for finding/fixing.
> This means that GUI applications that define their own loggers might miss
> warnings. This patch addresses this, and also fixes the relevant parts of
> utf8.c that have the same issue.
>
> Regards,
>
> /Pete
>
> PS: this patch has been pushed to -pbatard as well
>
> From 3a202e258d15ad51af4252be5b1b3c733ae7dd63 Mon Sep 17 00:00:00 2001
> From: Pete Batard <address@hidden>
> Date: Tue, 24 Jan 2012 18:51:54 +0000
> Subject: [PATCH] Use cdio logging facility for all warnings
>
> ---
> lib/driver/utf8.c | 5 +++--
> lib/udf/udf_file.c | 18 +++++++++---------
> 2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/lib/driver/utf8.c b/lib/driver/utf8.c
> index 9e7a901..ac5c491 100644
> --- a/lib/driver/utf8.c
> +++ b/lib/driver/utf8.c
> @@ -40,6 +40,7 @@
> #endif
>
> #include <cdio/utf8.h>
> +#include <cdio/logging.h>
>
> #include <stdio.h>
>
> @@ -142,13 +143,13 @@ do_convert(iconv_t cd, char * src, int src_len,
> ret = realloc(ret, alloc_size);
> if (ret == NULL)
> {
> - fprintf(stderr, "Can't realloc(%d).\n", alloc_size);
> + cdio_warn("Can't realloc(%d).", alloc_size);
> return false;
> }
> outbuf = ret + output_pos;
> break;
> default:
> - fprintf(stderr, "Iconv failed: %s\n", strerror(errno));
> + cdio_warn("Iconv failed: %s", strerror(errno));
> if (ret != NULL)
> free(ret);
> return false;
> diff --git a/lib/udf/udf_file.c b/lib/udf/udf_file.c
> index 1b3ddab..8ad1e91 100644
> --- a/lib/udf/udf_file.c
> +++ b/lib/udf/udf_file.c
> @@ -123,7 +123,7 @@ offset_to_lba(const udf_dirent_t *p_udf_dirent, off_t
> i_offset,
>
> switch (strat_type) {
> case 4096:
> - printf("Cannot deal with strategy4096 yet!\n");
> + cdio_warn("Cannot deal with strategy4096 yet!");
> return CDIO_INVALID_LBA;
> break;
> case ICBTAG_STRATEGY_TYPE_4:
> @@ -146,7 +146,7 @@ offset_to_lba(const udf_dirent_t *p_udf_dirent, off_t
> i_offset,
> i_offset -= icblen;
> ad_offset = sizeof(udf_short_ad_t) * ad_num;
> if (ad_offset > uint32_from_le(p_udf_fe->i_alloc_descs)) {
> - printf("File offset out of bounds\n");
> + cdio_warn("File offset out of bounds");
> return CDIO_INVALID_LBA;
> }
> p_icb = (udf_short_ad_t *)
> @@ -173,7 +173,7 @@ offset_to_lba(const udf_dirent_t *p_udf_dirent, off_t
> i_offset,
> i_offset -= icblen;
> ad_offset = sizeof(udf_long_ad_t) * ad_num;
> if (ad_offset > uint32_from_le(p_udf_fe->i_alloc_descs)) {
> - printf("File offset out of bounds\n");
> + cdio_warn("File offset out of bounds");
> return CDIO_INVALID_LBA;
> }
> p_icb = (udf_long_ad_t *)
> @@ -195,13 +195,13 @@ offset_to_lba(const udf_dirent_t *p_udf_dirent,
> off_t i_offset,
> * allocation descriptor field of the file entry.
> */
> *pi_max_size = 0;
> - printf("Don't know how to data in ICB handle yet\n");
> + cdio_warn("Don't know how to data in ICB handle yet");
> return CDIO_INVALID_LBA;
> case ICBTAG_FLAG_AD_EXTENDED:
> - printf("Don't know how to handle extended addresses yet\n");
> + cdio_warn("Don't know how to handle extended addresses yet");
> return CDIO_INVALID_LBA;
> default:
> - printf("Unsupported allocation descriptor %d\n", addr_ilk);
> + cdio_warn("Unsupported allocation descriptor %d", addr_ilk);
> return CDIO_INVALID_LBA;
> }
>
> @@ -213,7 +213,7 @@ offset_to_lba(const udf_dirent_t *p_udf_dirent, off_t
> i_offset,
> return *pi_lba;
> }
> default:
> - printf("Unknown strategy type %d\n", strat_type);
> + cdio_warn("Unknown strategy type %d", strat_type);
> return DRIVER_OP_ERROR;
> }
> }
> @@ -246,9 +246,9 @@ udf_read_block(const udf_dirent_t *p_udf_dirent, void
> * buf, size_t count)
> if (i_lba != CDIO_INVALID_LBA) {
> uint32_t i_max_blocks = CEILING(i_max_size, UDF_BLOCKSIZE);
> if ( i_max_blocks < count ) {
> - fprintf(stderr, "Warning: read count %u is larger than %u extent
> size.\n",
> + cdio_warn("read count %u is larger than %u extent size.",
> count, i_max_blocks);
> - fprintf(stderr, "Warning: read count truncated to %u\n", count);
> + cdio_warn("read count truncated to %u", count);
> count = i_max_blocks;
> }
> ret = udf_read_sectors(p_udf, buf, i_lba, count);
> --
> 1.7.8.msysgit.0
>
>
>