diff options
author | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-09-20 12:42:24 +0000 |
---|---|---|
committer | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-09-20 12:42:24 +0000 |
commit | a50a6282d7d3b40a4c9aa64a174f2cae5dbb5472 (patch) | |
tree | db8387b3ae741d7eb04280596c612040c977b91e /block-raw.c | |
parent | cbecba264bb870608ffbf7c9df8102116432a7df (diff) |
Use logfile only when loglevel is set (http://bugzilla.openmoko.org/cgi-bin/bugz
illa/show_bug.cgi?id=886).
raw_pread() and raw_pwrite() are expected to return number of bytes read.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3193 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block-raw.c')
-rw-r--r-- | block-raw.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/block-raw.c b/block-raw.c index b7a3eb6988..7c6f9640b3 100644 --- a/block-raw.c +++ b/block-raw.c @@ -61,7 +61,8 @@ #define DEBUG_BLOCK #if defined(DEBUG_BLOCK) && !defined(QEMU_TOOL) -#define DEBUG_BLOCK_PRINT(formatCstr, args...) fprintf(logfile, formatCstr, ##args); fflush(logfile) +#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \ + { fprintf(stderr, formatCstr, ##args); fflush(stderr); } } while (0) #else #define DEBUG_BLOCK_PRINT(formatCstr, args...) #endif @@ -162,7 +163,7 @@ static int raw_pread(BlockDriverState *bs, int64_t offset, if (ret == count) goto label__raw_read__success; - DEBUG_BLOCK_PRINT("raw_read(%d:%s, %lld, %p, %d) [%lld] read failed %d : %d = %s\n", + DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %lld, %p, %d) [%lld] read failed %d : %d = %s\n", s->fd, bs->filename, offset, buf, count, bs->total_sectors, ret, errno, strerror(errno)); @@ -177,13 +178,11 @@ static int raw_pread(BlockDriverState *bs, int64_t offset, if (ret == count) goto label__raw_read__success; - DEBUG_BLOCK_PRINT("raw_read(%d:%s, %lld, %p, %d) [%lld] retry read failed %d : %d = %s\n", + DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %lld, %p, %d) [%lld] retry read failed %d : %d = %s\n", s->fd, bs->filename, offset, buf, count, bs->total_sectors, ret, errno, strerror(errno)); } - return -1; - label__raw_read__success: return ret; @@ -202,7 +201,7 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset, if (lseek(s->fd, offset, SEEK_SET) == (off_t)-1) { ++(s->lseek_err_cnt); if(s->lseek_err_cnt) { - DEBUG_BLOCK_PRINT("raw_write(%d:%s, %lld, %p, %d) [%lld] lseek failed : %d = %s\n", + DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %lld, %p, %d) [%lld] lseek failed : %d = %s\n", s->fd, bs->filename, offset, buf, count, bs->total_sectors, errno, strerror(errno)); } @@ -214,12 +213,10 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset, if (ret == count) goto label__raw_write__success; - DEBUG_BLOCK_PRINT("raw_write(%d:%s, %lld, %p, %d) [%lld] write failed %d : %d = %s\n", + DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %lld, %p, %d) [%lld] write failed %d : %d = %s\n", s->fd, bs->filename, offset, buf, count, bs->total_sectors, ret, errno, strerror(errno)); - return -1; - label__raw_write__success: return ret; |