Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/dist/iscsi - use <inttypes.h> and PRIu64 in many places.
details: https://anonhg.NetBSD.org/src/rev/29c0e2451ece
branches: trunk
changeset: 588138:29c0e2451ece
user: mrg <mrg%NetBSD.org@localhost>
date: Thu Feb 09 08:46:43 2006 +0000
description:
- use <inttypes.h> and PRIu64 in many places.
- don't try to use the return value of NTOHL().
fixes sparc64 build problems.
diffstat:
dist/iscsi/include/util.h | 2 +-
dist/iscsi/src/disk.c | 22 ++++++++++----------
dist/iscsi/src/iscsi.c | 48 +++++++++++++++++++++++++---------------------
dist/iscsi/src/target.c | 11 +++++++--
dist/iscsi/src/util.c | 8 +++---
5 files changed, 50 insertions(+), 41 deletions(-)
diffs (truncated from 396 to 300 lines):
diff -r 7aafdfb377a9 -r 29c0e2451ece dist/iscsi/include/util.h
--- a/dist/iscsi/include/util.h Thu Feb 09 03:14:31 2006 +0000
+++ b/dist/iscsi/include/util.h Thu Feb 09 08:46:43 2006 +0000
@@ -561,7 +561,7 @@
#define NO_CLEANUP {}
#define RETURN_GREATER(NAME, V1, V2, CU, RC) \
if ((V1)>(V2)) { \
- TRACE_ERROR("Bad \"%s\": %u > %u.\n", NAME, V1, V2); \
+ TRACE_ERROR("Bad \"%s\": %u > %u.\n", NAME, (unsigned)V1, (unsigned)V2); \
CU; \
return RC; \
}
diff -r 7aafdfb377a9 -r 29c0e2451ece dist/iscsi/src/disk.c
--- a/dist/iscsi/src/disk.c Thu Feb 09 03:14:31 2006 +0000
+++ b/dist/iscsi/src/disk.c Thu Feb 09 08:46:43 2006 +0000
@@ -690,7 +690,7 @@
case 4096:
break;
default:
- TRACE_ERROR("Invalid block len %lld. Choose one of 512, 1024, 2048, 4096.\n", disks.v[disks.c].blocklen);
+ TRACE_ERROR("Invalid block len %" PRIu64 ". Choose one of 512, 1024, 2048, 4096.\n", disks.v[disks.c].blocklen);
return -1;
}
#if 0
@@ -700,7 +700,7 @@
#else
disks.v[disks.c].type = ISCSI_FS;
#endif
- PRINT("DISK: %lld logical units (%lld blocks, %lld bytes/block), type %s\n",
+ PRINT("DISK: %" PRIu64 " logical units (%" PRIu64 " blocks, %" PRIu64 " bytes/block), type %s\n",
disks.v[disks.c].luns, disks.v[disks.c].blockc, disks.v[disks.c].blocklen,
(disks.v[disks.c].type == ISCSI_FS) ? "iscsi fs" :
(disks.v[disks.c].type == ISCSI_FS_MMAP) ? "iscsi fs mmap" : "iscsi ramdisk");
@@ -712,8 +712,8 @@
TRACE_ERROR("iscsi_malloc() failed\n");
return -1;
}
- TRACE(TRACE_ISCSI_DEBUG, "allocated %lld bytes at %p\n", disks.v[disks.c].size, disks.v[disks.c].ramdisk[i]);
- PRINT("%lld MB ramdisk\n", disks.v[disks.c].size / MB(1));
+ TRACE(TRACE_ISCSI_DEBUG, "allocated %" PRIu64 " bytes at %p\n", disks.v[disks.c].size, disks.v[disks.c].ramdisk[i]);
+ PRINT("%" PRIu64 " MB ramdisk\n", disks.v[disks.c].size / MB(1));
} else {
(void) strlcpy(disks.v[disks.c].filename, disc_get_filename(&tp->de), sizeof(disks.v[disks.c].filename));
if (de_open(&tp->de, O_CREAT | O_RDWR, 0666) == -1) {
@@ -739,7 +739,7 @@
TRACE_ERROR("error allocating space for \"%s\"", tp->target);
return -1;
}
- PRINT("%llu MB disk storage for \"%s\"\n", (de_getsize(&tp->de) / MB(1)), tp->target);
+ PRINT("%" PRIu64 " MB disk storage for \"%s\"\n", (de_getsize(&tp->de) / MB(1)), tp->target);
#endif
}
}
@@ -1014,7 +1014,7 @@
struct iovec sg;
uint64_t extra = 0;
- TRACE(TRACE_SCSI_DATA, "writing %lld bytes from socket into device at byte offset %lld\n", num_bytes, byte_offset);
+ TRACE(TRACE_SCSI_DATA, "writing %" PRIu64 " bytes from socket into device at byte offset %" PRIu64 "\n", num_bytes, byte_offset);
/* Assign ptr for write data */
@@ -1047,11 +1047,11 @@
switch(disks.v[sess->d].type) {
case ISCSI_FS:
if (de_lseek(&disks.v[sess->d].tv->v[sess->d].de, (off_t) byte_offset, SEEK_SET) == -1) {
- TRACE_ERROR("lseek() to offset %lld failed\n", byte_offset);
+ TRACE_ERROR("lseek() to offset %" PRIu64 " failed\n", byte_offset);
return -1;
}
if (de_write(&disks.v[sess->d].tv->v[sess->d].de, ptr, (unsigned) num_bytes) != num_bytes) {
- TRACE_ERROR("write() of %lld bytes failed at offset %lld, size %lld\n", num_bytes, byte_offset, de_getsize(&disks.v[sess->d].tv->v[0].de));
+ TRACE_ERROR("write() of %" PRIu64 " bytes failed at offset %" PRIu64 ", size %" PRIu64 "\n", num_bytes, byte_offset, de_getsize(&disks.v[sess->d].tv->v[0].de));
return -1;
}
break;
@@ -1062,7 +1062,7 @@
return -1;
}
}
- TRACE(TRACE_SCSI_DATA, "wrote %lld bytes to device OK\n", num_bytes);
+ TRACE(TRACE_SCSI_DATA, "wrote %" PRIu64 " bytes to device OK\n", num_bytes);
return 0;
}
@@ -1096,7 +1096,7 @@
RETURN_EQUAL("len", len, 0, NO_CLEANUP, -1);
if ((lba > (disks.v[sess->d].blockc - 1)) || ((lba + len) > disks.v[sess->d].blockc)) {
TRACE_ERROR("attempt to read beyond end of media\n");
- TRACE_ERROR("max_lba = %lld, requested lba = %u, len = %u\n", disks.v[sess->d].blockc - 1, lba, len);
+ TRACE_ERROR("max_lba = %" PRIu64 ", requested lba = %u, len = %u\n", disks.v[sess->d].blockc - 1, lba, len);
return -1;
}
switch (disks.v[sess->d].type) {
@@ -1119,7 +1119,7 @@
}
n += rc;
if (n < num_bytes) {
- TRACE_ERROR("Got partial file read: %i bytes of %lld\n", rc, num_bytes - n + rc);
+ TRACE_ERROR("Got partial file read: %i bytes of %" PRIu64 "\n", rc, num_bytes - n + rc);
}
} while (n < num_bytes);
break;
diff -r 7aafdfb377a9 -r 29c0e2451ece dist/iscsi/src/iscsi.c
--- a/dist/iscsi/src/iscsi.c Thu Feb 09 03:14:31 2006 +0000
+++ b/dist/iscsi/src/iscsi.c Thu Feb 09 08:46:43 2006 +0000
@@ -46,6 +46,10 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
#include "iscsi.h"
#include "util.h"
@@ -60,7 +64,7 @@
{
TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
TRACE(TRACE_ISCSI_ARGS, "Function: %u\n", cmd->function);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Ref Tag: 0x%x\n", cmd->ref_tag);
TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN);
@@ -110,7 +114,7 @@
TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
TRACE(TRACE_ISCSI_ARGS, "Function: %u\n", cmd->function);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Ref Tag: 0x%x\n", cmd->ref_tag);
TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN);
@@ -197,7 +201,7 @@
TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN);
@@ -245,7 +249,7 @@
TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN);
@@ -264,7 +268,7 @@
uint32_t length;
TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN);
@@ -313,7 +317,7 @@
RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1);
TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN);
@@ -335,7 +339,7 @@
TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final);
TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont);
TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN);
@@ -392,7 +396,7 @@
TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final);
TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont);
TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN);
@@ -413,7 +417,7 @@
TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", rsp->final);
TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont);
TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", rsp->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", rsp->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", rsp->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN);
@@ -467,7 +471,7 @@
TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", rsp->final);
TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont);
TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", rsp->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", rsp->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", rsp->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN);
@@ -494,7 +498,7 @@
TRACE(TRACE_ISCSI_ARGS, "Version_max: %u\n", cmd->version_max);
TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength);
TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "ISID: %llu\n", cmd->isid);
+ TRACE(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", cmd->isid);
TRACE(TRACE_ISCSI_ARGS, "TSIH: %hu\n", cmd->tsih);
TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid);
@@ -554,7 +558,7 @@
TRACE(TRACE_ISCSI_ARGS, "Version_max: %u\n", cmd->version_max);
TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength);
TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "ISID: %llu\n", cmd->isid);
+ TRACE(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", cmd->isid);
TRACE(TRACE_ISCSI_ARGS, "TSIH: %hu\n", cmd->tsih);
TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid);
@@ -593,7 +597,7 @@
TRACE(TRACE_ISCSI_ARGS, "Version_active: %u\n", rsp->version_active);
TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", rsp->AHSlength);
TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length);
- TRACE(TRACE_ISCSI_ARGS, "ISID: %llu\n", rsp->isid);
+ TRACE(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", rsp->isid);
TRACE(TRACE_ISCSI_ARGS, "TSIH: %u\n", rsp->tsih);
TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag);
TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN);
@@ -661,7 +665,7 @@
TRACE(TRACE_ISCSI_ARGS, "Version_active: %u\n", rsp->version_active);
TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", rsp->AHSlength);
TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length);
- TRACE(TRACE_ISCSI_ARGS, "ISID: %llu\n", rsp->isid);
+ TRACE(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", rsp->isid);
TRACE(TRACE_ISCSI_ARGS, "TSIH: %u\n", rsp->tsih);
TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag);
TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN);
@@ -832,7 +836,7 @@
TRACE(TRACE_ISCSI_ARGS, "ATTR: %i\n", cmd->attr);
TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->ahs_len);
TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Length: %u\n", cmd->trans_len);
TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN);
@@ -897,7 +901,7 @@
TRACE(TRACE_ISCSI_ARGS, "ATTR: %i\n", cmd->attr);
TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->ahs_len);
TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Length: %u\n", cmd->trans_len);
TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN);
@@ -1016,7 +1020,7 @@
uint32_t length;
TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN);
@@ -1070,7 +1074,7 @@
RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *) (void *) (header + 12)), 0, NO_CLEANUP, 1);
TRACE(TRACE_ISCSI_ARGS, "AHSLength: %u\n", cmd->AHSlength);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN);
@@ -1092,7 +1096,7 @@
TRACE(TRACE_ISCSI_ARGS, "Final: %u\n", cmd->final);
TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN);
@@ -1139,7 +1143,7 @@
TRACE(TRACE_ISCSI_ARGS, "Final: %u\n", cmd->final);
TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length);
- TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun);
TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag);
TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag);
TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN);
@@ -1164,7 +1168,7 @@
TRACE(TRACE_ISCSI_ARGS, "S_bit: %i\n", cmd->S_bit);
TRACE(TRACE_ISCSI_ARGS, "Status: %u\n", cmd->status);
Home |
Main Index |
Thread Index |
Old Index