Commit a50a6282d7d3b40a4c9aa64a174f2cae5dbb5472
1 parent
cbecba26
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
Showing
1 changed file
with
6 additions
and
9 deletions
block-raw.c
| ... | ... | @@ -61,7 +61,8 @@ |
| 61 | 61 | |
| 62 | 62 | #define DEBUG_BLOCK |
| 63 | 63 | #if defined(DEBUG_BLOCK) && !defined(QEMU_TOOL) |
| 64 | -#define DEBUG_BLOCK_PRINT(formatCstr, args...) fprintf(logfile, formatCstr, ##args); fflush(logfile) | |
| 64 | +#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \ | |
| 65 | + { fprintf(stderr, formatCstr, ##args); fflush(stderr); } } while (0) | |
| 65 | 66 | #else |
| 66 | 67 | #define DEBUG_BLOCK_PRINT(formatCstr, args...) |
| 67 | 68 | #endif |
| ... | ... | @@ -162,7 +163,7 @@ static int raw_pread(BlockDriverState *bs, int64_t offset, |
| 162 | 163 | if (ret == count) |
| 163 | 164 | goto label__raw_read__success; |
| 164 | 165 | |
| 165 | - DEBUG_BLOCK_PRINT("raw_read(%d:%s, %lld, %p, %d) [%lld] read failed %d : %d = %s\n", | |
| 166 | + DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %lld, %p, %d) [%lld] read failed %d : %d = %s\n", | |
| 166 | 167 | s->fd, bs->filename, offset, buf, count, |
| 167 | 168 | bs->total_sectors, ret, errno, strerror(errno)); |
| 168 | 169 | |
| ... | ... | @@ -177,13 +178,11 @@ static int raw_pread(BlockDriverState *bs, int64_t offset, |
| 177 | 178 | if (ret == count) |
| 178 | 179 | goto label__raw_read__success; |
| 179 | 180 | |
| 180 | - DEBUG_BLOCK_PRINT("raw_read(%d:%s, %lld, %p, %d) [%lld] retry read failed %d : %d = %s\n", | |
| 181 | + DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %lld, %p, %d) [%lld] retry read failed %d : %d = %s\n", | |
| 181 | 182 | s->fd, bs->filename, offset, buf, count, |
| 182 | 183 | bs->total_sectors, ret, errno, strerror(errno)); |
| 183 | 184 | } |
| 184 | 185 | |
| 185 | - return -1; | |
| 186 | - | |
| 187 | 186 | label__raw_read__success: |
| 188 | 187 | |
| 189 | 188 | return ret; |
| ... | ... | @@ -202,7 +201,7 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset, |
| 202 | 201 | if (lseek(s->fd, offset, SEEK_SET) == (off_t)-1) { |
| 203 | 202 | ++(s->lseek_err_cnt); |
| 204 | 203 | if(s->lseek_err_cnt) { |
| 205 | - DEBUG_BLOCK_PRINT("raw_write(%d:%s, %lld, %p, %d) [%lld] lseek failed : %d = %s\n", | |
| 204 | + DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %lld, %p, %d) [%lld] lseek failed : %d = %s\n", | |
| 206 | 205 | s->fd, bs->filename, offset, buf, count, |
| 207 | 206 | bs->total_sectors, errno, strerror(errno)); |
| 208 | 207 | } |
| ... | ... | @@ -214,12 +213,10 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset, |
| 214 | 213 | if (ret == count) |
| 215 | 214 | goto label__raw_write__success; |
| 216 | 215 | |
| 217 | - DEBUG_BLOCK_PRINT("raw_write(%d:%s, %lld, %p, %d) [%lld] write failed %d : %d = %s\n", | |
| 216 | + DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %lld, %p, %d) [%lld] write failed %d : %d = %s\n", | |
| 218 | 217 | s->fd, bs->filename, offset, buf, count, |
| 219 | 218 | bs->total_sectors, ret, errno, strerror(errno)); |
| 220 | 219 | |
| 221 | - return -1; | |
| 222 | - | |
| 223 | 220 | label__raw_write__success: |
| 224 | 221 | |
| 225 | 222 | return ret; | ... | ... |