Skip to content

Commit 839fd7f

Browse files
committed
u64 -> uint64_t, u32 -> uint32_t
Signed-off-by: Lars H. Rohwedder <RokerHRO@users.noreply.github.com>
1 parent 39dc924 commit 839fd7f

File tree

6 files changed

+26
-48
lines changed

6 files changed

+26
-48
lines changed

cliserv.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include <cliserv.h>
1010
#include <nbd-debug.h>
1111

12-
const u64 cliserv_magic = 0x00420281861253LL;
13-
const u64 opts_magic = 0x49484156454F5054LL;
14-
const u64 rep_magic = 0x3e889045565a9LL;
12+
const uint64_t cliserv_magic = 0x00420281861253LL;
13+
const uint64_t opts_magic = 0x49484156454F5054LL;
14+
const uint64_t rep_magic = 0x3e889045565a9LL;
1515

1616
/**
1717
* Set a socket to blocking or non-blocking
@@ -99,8 +99,8 @@ uint64_t ntohll(uint64_t a) {
9999
}
100100
#else
101101
uint64_t ntohll(uint64_t a) {
102-
u32 lo = a & 0xffffffff;
103-
u32 hi = a >> 32U;
102+
uint32_t lo = a & 0xffffffff;
103+
uint32_t hi = a >> 32U;
104104
lo = ntohl(lo);
105105
hi = ntohl(hi);
106106
return ((uint64_t) lo) << 32U | hi;

cliserv.h

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,6 @@
1616
#include <netinet/in.h>
1717
#include <stdlib.h>
1818

19-
#if SIZEOF_UNSIGNED_SHORT_INT==4
20-
typedef unsigned short u32;
21-
#elif SIZEOF_UNSIGNED_INT==4
22-
typedef unsigned int u32;
23-
#elif SIZEOF_UNSIGNED_LONG_INT==4
24-
typedef unsigned long u32;
25-
#else
26-
#error I need at least some 32-bit type
27-
#endif
28-
29-
#if SIZEOF_UNSIGNED_INT==8
30-
typedef unsigned int u64;
31-
#elif SIZEOF_UNSIGNED_LONG_INT==8
32-
typedef unsigned long u64;
33-
#elif SIZEOF_UNSIGNED_LONG_LONG_INT==8
34-
typedef unsigned long long u64;
35-
#else
36-
#error I need at least some 64-bit type
37-
#endif
38-
39-
#define __be32 u32
40-
#define __be64 u64
4119
#include "nbd.h"
4220

4321
#ifndef HAVE_FDATASYNC
@@ -64,9 +42,9 @@ typedef unsigned long long u64;
6442
#endif
6543
#endif
6644

67-
extern const u64 cliserv_magic;
68-
extern const u64 opts_magic;
69-
extern const u64 rep_magic;
45+
extern const uint64_t cliserv_magic;
46+
extern const uint64_t opts_magic;
47+
extern const uint64_t rep_magic;
7048

7149
#define INIT_PASSWD "NBDMAGIC"
7250

nbd-client.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static struct nl_sock *get_nbd_socket(int *driver_id) {
163163
}
164164

165165
static void netlink_configure(int index, int *sockfds, int num_connects,
166-
u64 size64, int blocksize, uint16_t flags,
166+
uint64_t size64, int blocksize, uint16_t flags,
167167
int timeout, const char *identifier) {
168168
struct nl_sock *socket;
169169
struct nlattr *sock_attr;
@@ -247,7 +247,7 @@ static void netlink_disconnect(char *nbddev) {
247247
}
248248
#else
249249
static void netlink_configure(int index, int *sockfds, int num_connects,
250-
u64 size64, int blocksize, uint16_t flags,
250+
uint64_t size64, int blocksize, uint16_t flags,
251251
int timeout, const char *identifier)
252252
{
253253
}
@@ -557,7 +557,7 @@ void send_opt_exportname(int sock, uint16_t *flags, char* name, uint16_t global_
557557
}
558558

559559
void negotiate(int *sockp, uint16_t *flags, uint32_t needed_flags, uint32_t client_flags, uint32_t do_opts) {
560-
u64 magic;
560+
uint64_t magic;
561561
uint16_t tmp;
562562
uint16_t global_flags;
563563
char buf[256] = "\0\0\0\0\0\0\0\0\0";
@@ -791,22 +791,22 @@ bool get_from_config() {
791791
return retval;
792792
}
793793

794-
void setsizes(int nbd, u64 size64, int blocksize, u32 flags) {
794+
void setsizes(int nbd, uint64_t size64, int blocksize, uint32_t flags) {
795795
unsigned long size;
796796
int read_only = (flags & NBD_FLAG_READ_ONLY) ? 1 : 0;
797797

798798
if (size64>>12 > (uint64_t)~0UL)
799799
err("Device too large.\n");
800800
else {
801801
int tmp_blocksize = 4096;
802-
if (size64 / (u64)blocksize <= (uint64_t)~0UL)
802+
if (size64 / (uint64_t)blocksize <= (uint64_t)~0UL)
803803
tmp_blocksize = blocksize;
804804
if (ioctl(nbd, NBD_SET_BLKSIZE, tmp_blocksize) < 0) {
805805
fprintf(stderr, "Failed to set blocksize %d\n",
806806
tmp_blocksize);
807807
err("Ioctl/1.1a failed: %m\n");
808808
}
809-
size = (unsigned long)(size64 / (u64)tmp_blocksize);
809+
size = (unsigned long)(size64 / (uint64_t)tmp_blocksize);
810810
if (ioctl(nbd, NBD_SET_SIZE_BLOCKS, size) < 0)
811811
err("Ioctl/1.1b failed: %m\n");
812812
if (tmp_blocksize != blocksize) {
@@ -816,7 +816,7 @@ void setsizes(int nbd, u64 size64, int blocksize, u32 flags) {
816816
err("Ioctl/1.1c failed: %m\n");
817817
}
818818
}
819-
fprintf(stderr, "bs=%d, sz=%" PRIu64 " bytes\n", blocksize, (u64)tmp_blocksize * size);
819+
fprintf(stderr, "bs=%d, sz=%" PRIu64 " bytes\n", blocksize, (uint64_t)tmp_blocksize * size);
820820
}
821821

822822
ioctl(nbd, NBD_CLEAR_SOCK);

nbd-server.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ int expread(READ_CTX *ctx, CLIENT *client) {
15751575
len : (size_t)DIFFPAGESIZE-offset;
15761576
if (!(client->server->flags & F_COPYONWRITE))
15771577
pthread_rwlock_rdlock(&client->export_lock);
1578-
if (client->difmap[mapcnt]!=(u32)(-1)) { /* the block is already there */
1578+
if (client->difmap[mapcnt]!=(uint32_t)(-1)) { /* the block is already there */
15791579
DEBUG("Page %llu is at %lu\n", (unsigned long long)mapcnt,
15801580
(unsigned long)(client->difmap[mapcnt]));
15811581
char *buf = find_read_buf(ctx);
@@ -1645,7 +1645,7 @@ int expwrite(off_t a, char *buf, size_t len, CLIENT *client, int fua) {
16451645

16461646
if (!(client->server->flags & F_COPYONWRITE))
16471647
pthread_rwlock_rdlock(&client->export_lock);
1648-
if (client->difmap[mapcnt]!=(u32)(-1)) { /* the block is already there */
1648+
if (client->difmap[mapcnt]!=(uint32_t)(-1)) { /* the block is already there */
16491649
DEBUG("Page %llu is at %lu\n", (unsigned long long)mapcnt,
16501650
(unsigned long)(client->difmap[mapcnt])) ;
16511651
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){
19451945
offset = DIFFPAGESIZE*i;
19461946
if (lock)
19471947
pthread_rwlock_wrlock(&client->export_lock);
1948-
if (client->difmap[i] != (u32)-1){
1948+
if (client->difmap[i] != (uint32_t)-1){
19491949
dirtycount += 1;
19501950
DEBUG("flushing dirty page %d, offset %ld\n", i, offset);
19511951
if (pread(client->difffile, buf, DIFFPAGESIZE, client->difmap[i]*DIFFPAGESIZE) != DIFFPAGESIZE) {
@@ -1962,7 +1962,7 @@ int commit_diff(CLIENT* client, bool lock, int fhandle){
19621962
}
19631963
break;
19641964
}
1965-
client->difmap[i] = (u32)-1;
1965+
client->difmap[i] = (uint32_t)-1;
19661966
}
19671967
if (lock)
19681968
pthread_rwlock_unlock(&client->export_lock);
@@ -2158,17 +2158,17 @@ bool copyonwrite_prepare(CLIENT* client) {
21582158
err("Could not create diff file (%m)");
21592159
return false;
21602160
}
2161-
if ((client->difmap=calloc(client->exportsize/DIFFPAGESIZE,sizeof(u32)))==NULL) {
2161+
if ((client->difmap=calloc(client->exportsize/DIFFPAGESIZE,sizeof(uint32_t)))==NULL) {
21622162
err("Could not allocate memory");
21632163
return false;
21642164
}
2165-
for (i=0;i<client->exportsize/DIFFPAGESIZE;i++) client->difmap[i]=(u32)-1;
2165+
for (i=0;i<client->exportsize/DIFFPAGESIZE;i++) client->difmap[i]=(uint32_t)-1;
21662166

21672167
return true;
21682168
}
21692169

21702170
void send_export_info(CLIENT* client, SERVER* server, bool maybe_zeroes) {
2171-
uint64_t size_host = htonll((u64)(client->exportsize));
2171+
uint64_t size_host = htonll((uint64_t)(client->exportsize));
21722172
uint16_t flags = NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_WRITE_ZEROES;
21732173

21742174
socket_write(client, &size_host, 8);

nbdsrv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ SERVER* dup_serve(const SERVER *const s) {
228228

229229
uint64_t size_autodetect(int fhandle) {
230230
off_t es;
231-
u64 bytes __attribute__((unused));
231+
uint64_t bytes __attribute__((unused));
232232
struct stat stat_buf;
233233
int error;
234234

tests/run/nbd-tester-client.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ int setup_connection_common(int sock, char *name, CONNECTION_TYPE ctype,
363363
int *serverflags, int testflags)
364364
{
365365
char buf[256];
366-
u64 tmp64;
366+
uint64_t tmp64;
367367
uint64_t mymagic = (name ? opts_magic : cliserv_magic);
368368
uint32_t tmp32 = 0;
369369
uint16_t handshakeflags = 0;
@@ -675,7 +675,7 @@ int setup_inetd_connection(gchar **argv)
675675
int close_connection(int sock, CLOSE_TYPE type)
676676
{
677677
struct nbd_request req;
678-
u64 counter = 0;
678+
uint64_t counter = 0;
679679

680680
switch (type) {
681681
case CONNECTION_CLOSE_PROPERLY:
@@ -831,7 +831,7 @@ int handshake_test(char *name, int sock, char close_sock, int testflags)
831831
{
832832
int retval = -1;
833833
int serverflags = 0;
834-
u64 tmp64;
834+
uint64_t tmp64;
835835
uint32_t tmp32 = 0;
836836

837837
/* This should work */

0 commit comments

Comments
 (0)