diff --git a/cliserv.c b/cliserv.c index d317ecd5..651145f8 100644 --- a/cliserv.c +++ b/cliserv.c @@ -9,9 +9,9 @@ #include #include -const u64 cliserv_magic = 0x00420281861253LL; -const u64 opts_magic = 0x49484156454F5054LL; -const u64 rep_magic = 0x3e889045565a9LL; +const uint64_t cliserv_magic = 0x00420281861253LL; +const uint64_t opts_magic = 0x49484156454F5054LL; +const uint64_t rep_magic = 0x3e889045565a9LL; /** * Set a socket to blocking or non-blocking @@ -99,8 +99,8 @@ uint64_t ntohll(uint64_t a) { } #else uint64_t ntohll(uint64_t a) { - u32 lo = a & 0xffffffff; - u32 hi = a >> 32U; + uint32_t lo = a & 0xffffffff; + uint32_t hi = a >> 32U; lo = ntohl(lo); hi = ntohl(hi); return ((uint64_t) lo) << 32U | hi; diff --git a/cliserv.h b/cliserv.h index 5a76ec8d..9e2d8c01 100644 --- a/cliserv.h +++ b/cliserv.h @@ -16,28 +16,6 @@ #include #include -#if SIZEOF_UNSIGNED_SHORT_INT==4 -typedef unsigned short u32; -#elif SIZEOF_UNSIGNED_INT==4 -typedef unsigned int u32; -#elif SIZEOF_UNSIGNED_LONG_INT==4 -typedef unsigned long u32; -#else -#error I need at least some 32-bit type -#endif - -#if SIZEOF_UNSIGNED_INT==8 -typedef unsigned int u64; -#elif SIZEOF_UNSIGNED_LONG_INT==8 -typedef unsigned long u64; -#elif SIZEOF_UNSIGNED_LONG_LONG_INT==8 -typedef unsigned long long u64; -#else -#error I need at least some 64-bit type -#endif - -#define __be32 u32 -#define __be64 u64 #include "nbd.h" #ifndef HAVE_FDATASYNC @@ -64,9 +42,9 @@ typedef unsigned long long u64; #endif #endif -extern const u64 cliserv_magic; -extern const u64 opts_magic; -extern const u64 rep_magic; +extern const uint64_t cliserv_magic; +extern const uint64_t opts_magic; +extern const uint64_t rep_magic; #define INIT_PASSWD "NBDMAGIC" diff --git a/nbd-client.c b/nbd-client.c index 158ec80f..9219d3f5 100644 --- a/nbd-client.c +++ b/nbd-client.c @@ -163,7 +163,7 @@ static struct nl_sock *get_nbd_socket(int *driver_id) { } static void netlink_configure(int index, int *sockfds, int num_connects, - u64 size64, int blocksize, uint16_t flags, + uint64_t size64, int blocksize, uint16_t flags, int timeout, const char *identifier) { struct nl_sock *socket; struct nlattr *sock_attr; @@ -247,7 +247,7 @@ static void netlink_disconnect(char *nbddev) { } #else static void netlink_configure(int index, int *sockfds, int num_connects, - u64 size64, int blocksize, uint16_t flags, + uint64_t size64, int blocksize, uint16_t flags, int timeout, const char *identifier) { } @@ -557,7 +557,7 @@ void send_opt_exportname(int sock, uint16_t *flags, char* name, uint16_t global_ } void negotiate(int *sockp, uint16_t *flags, uint32_t needed_flags, uint32_t client_flags, uint32_t do_opts) { - u64 magic; + uint64_t magic; uint16_t tmp; uint16_t global_flags; char buf[256] = "\0\0\0\0\0\0\0\0\0"; @@ -791,7 +791,7 @@ bool get_from_config() { return retval; } -void setsizes(int nbd, u64 size64, int blocksize, u32 flags) { +void setsizes(int nbd, uint64_t size64, int blocksize, uint32_t flags) { unsigned long size; int read_only = (flags & NBD_FLAG_READ_ONLY) ? 1 : 0; @@ -799,14 +799,14 @@ void setsizes(int nbd, u64 size64, int blocksize, u32 flags) { err("Device too large.\n"); else { int tmp_blocksize = 4096; - if (size64 / (u64)blocksize <= (uint64_t)~0UL) + if (size64 / (uint64_t)blocksize <= (uint64_t)~0UL) tmp_blocksize = blocksize; if (ioctl(nbd, NBD_SET_BLKSIZE, tmp_blocksize) < 0) { fprintf(stderr, "Failed to set blocksize %d\n", tmp_blocksize); err("Ioctl/1.1a failed: %m\n"); } - size = (unsigned long)(size64 / (u64)tmp_blocksize); + size = (unsigned long)(size64 / (uint64_t)tmp_blocksize); if (ioctl(nbd, NBD_SET_SIZE_BLOCKS, size) < 0) err("Ioctl/1.1b failed: %m\n"); if (tmp_blocksize != blocksize) { @@ -816,7 +816,7 @@ void setsizes(int nbd, u64 size64, int blocksize, u32 flags) { err("Ioctl/1.1c failed: %m\n"); } } - fprintf(stderr, "bs=%d, sz=%" PRIu64 " bytes\n", blocksize, (u64)tmp_blocksize * size); + fprintf(stderr, "bs=%d, sz=%" PRIu64 " bytes\n", blocksize, (uint64_t)tmp_blocksize * size); } ioctl(nbd, NBD_CLEAR_SOCK); diff --git a/nbd-server.c b/nbd-server.c index 7237533e..4c32d4b4 100644 --- a/nbd-server.c +++ b/nbd-server.c @@ -1575,7 +1575,7 @@ int expread(READ_CTX *ctx, CLIENT *client) { len : (size_t)DIFFPAGESIZE-offset; if (!(client->server->flags & F_COPYONWRITE)) pthread_rwlock_rdlock(&client->export_lock); - if (client->difmap[mapcnt]!=(u32)(-1)) { /* the block is already there */ + if (client->difmap[mapcnt]!=(uint32_t)(-1)) { /* the block is already there */ DEBUG("Page %llu is at %lu\n", (unsigned long long)mapcnt, (unsigned long)(client->difmap[mapcnt])); char *buf = find_read_buf(ctx); @@ -1645,7 +1645,7 @@ int expwrite(off_t a, char *buf, size_t len, CLIENT *client, int fua) { if (!(client->server->flags & F_COPYONWRITE)) pthread_rwlock_rdlock(&client->export_lock); - if (client->difmap[mapcnt]!=(u32)(-1)) { /* the block is already there */ + if (client->difmap[mapcnt]!=(uint32_t)(-1)) { /* the block is already there */ DEBUG("Page %llu is at %lu\n", (unsigned long long)mapcnt, (unsigned long)(client->difmap[mapcnt])) ; if (pwrite(client->difffile, buf, wrlen, client->difmap[mapcnt]*DIFFPAGESIZE+offset) != wrlen) goto fail; @@ -1945,7 +1945,7 @@ int commit_diff(CLIENT* client, bool lock, int fhandle){ offset = DIFFPAGESIZE*i; if (lock) pthread_rwlock_wrlock(&client->export_lock); - if (client->difmap[i] != (u32)-1){ + if (client->difmap[i] != (uint32_t)-1){ dirtycount += 1; DEBUG("flushing dirty page %d, offset %ld\n", i, offset); if (pread(client->difffile, buf, DIFFPAGESIZE, client->difmap[i]*DIFFPAGESIZE) != DIFFPAGESIZE) { @@ -1962,7 +1962,7 @@ int commit_diff(CLIENT* client, bool lock, int fhandle){ } break; } - client->difmap[i] = (u32)-1; + client->difmap[i] = (uint32_t)-1; } if (lock) pthread_rwlock_unlock(&client->export_lock); @@ -2158,17 +2158,17 @@ bool copyonwrite_prepare(CLIENT* client) { err("Could not create diff file (%m)"); return false; } - if ((client->difmap=calloc(client->exportsize/DIFFPAGESIZE,sizeof(u32)))==NULL) { + if ((client->difmap=calloc(client->exportsize/DIFFPAGESIZE,sizeof(uint32_t)))==NULL) { err("Could not allocate memory"); return false; } - for (i=0;iexportsize/DIFFPAGESIZE;i++) client->difmap[i]=(u32)-1; + for (i=0;iexportsize/DIFFPAGESIZE;i++) client->difmap[i]=(uint32_t)-1; return true; } void send_export_info(CLIENT* client, SERVER* server, bool maybe_zeroes) { - uint64_t size_host = htonll((u64)(client->exportsize)); + uint64_t size_host = htonll((uint64_t)(client->exportsize)); uint16_t flags = NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_WRITE_ZEROES; socket_write(client, &size_host, 8); diff --git a/nbdsrv.c b/nbdsrv.c index 3c6896c2..6b4182ec 100644 --- a/nbdsrv.c +++ b/nbdsrv.c @@ -228,7 +228,7 @@ SERVER* dup_serve(const SERVER *const s) { uint64_t size_autodetect(int fhandle) { off_t es; - u64 bytes __attribute__((unused)); + uint64_t bytes __attribute__((unused)); struct stat stat_buf; int error; diff --git a/tests/run/nbd-tester-client.c b/tests/run/nbd-tester-client.c index 0d28cd53..6daa8481 100644 --- a/tests/run/nbd-tester-client.c +++ b/tests/run/nbd-tester-client.c @@ -363,7 +363,7 @@ int setup_connection_common(int sock, char *name, CONNECTION_TYPE ctype, int *serverflags, int testflags) { char buf[256]; - u64 tmp64; + uint64_t tmp64; uint64_t mymagic = (name ? opts_magic : cliserv_magic); uint32_t tmp32 = 0; uint16_t handshakeflags = 0; @@ -675,7 +675,7 @@ int setup_inetd_connection(gchar **argv) int close_connection(int sock, CLOSE_TYPE type) { struct nbd_request req; - u64 counter = 0; + uint64_t counter = 0; switch (type) { case CONNECTION_CLOSE_PROPERLY: @@ -831,7 +831,7 @@ int handshake_test(char *name, int sock, char close_sock, int testflags) { int retval = -1; int serverflags = 0; - u64 tmp64; + uint64_t tmp64; uint32_t tmp32 = 0; /* This should work */