[libnbd PATCH v3 00/22] NBD 64-bit extensions (libnbd portion)
by Eric Blake
v2 was here:
https://listman.redhat.com/archives/libguestfs/2022-November/030292.html
For v3, there are now approved specs to code to:
https://listman.redhat.com/archives/libguestfs/2023-April/031251.html
visible on an upstream branch at
https://github.com/NetworkBlockDevice/nbd/blob/extension-ext-header/doc/p...
(upstream leaves extensions in a branch state until there are multiple
implementations that comply with that extension)
as well as interoperability with counterpart qemu patches:
https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg03607.html
also available at
https://repo.or.cz/qemu/ericb.git/shortlog/refs/tags/exthdr-v3
I'm still working on adding extended header support into nbdkit, which
will involve adding a v3 protocol for plugins; that work is probably
much further out.
Changes since v2:
001/22:[0002] [FC] 'block_status: Refactor array storage'
002/22:[0016] [FC] 'internal: Refactor layout of replies in sbuf'
003/22:[0002] [FC] 'protocol: Add definitions for extended headers'
004/22:[0006] [FC] 'states: Prepare to send 64-bit requests'
005/22:[0013] [FC] 'states: Prepare to receive 64-bit replies'
006/22:[0007] [FC] 'states: Break deadlock if server goofs on extended replies'
007/22:[0021] [FC] 'generator: Add struct nbd_extent in prep for 64-bit extents'
008/22:[----] [-C] 'block_status: Track 64-bit extents internally'
009/22:[0012] [FC] 'block_status: Accept 64-bit extents during block status'
010/22:[0063] [FC] 'api: Add [aio_]nbd_block_status_64'
011/22:[0006] [FC] 'api: Add several functions for controlling extended headers'
012/22:[----] [--] 'copy: Update nbdcopy to use 64-bit block status'
013/22:[0004] [FC] 'dump: Update nbddump to use 64-bit block status'
014/22:[----] [--] 'info: Expose extended-headers support through nbdinfo'
015/22:[0006] [FC] 'info: Update nbdinfo --map to use 64-bit block status'
016/22:[----] [-C] 'examples: Update copy-libev to use 64-bit block status'
017/22:[0002] [FC] 'ocaml: Add example for 64-bit extents'
018/22:[0004] [FC] 'generator: Actually request extended headers'
019/22:[0008] [FC] 'api: Add nbd_[aio_]opt_extended_headers()'
020/22:[0004] [FC] 'interop: Add test of 64-bit block status'
021/22:[0011] [FC] 'api: Add nbd_can_block_status_payload()'
022/22:[0004] [FC] 'api: Add nbd_[aio_]block_status_filter()'
The changes are mostly fallout from rebasing on top of style cleanups
that Laszlo has been working on, but also deal with some changes with
the spec compared to how it was proposed in v2 (for example, upstream
decided that for NBD_CMD_BLOCK_STATUS, the server should always use
64-bit replies, rather than making the client support both 32- and
64-bit replies).
Eric Blake (22):
block_status: Refactor array storage
internal: Refactor layout of replies in sbuf
protocol: Add definitions for extended headers
states: Prepare to send 64-bit requests
states: Prepare to receive 64-bit replies
states: Break deadlock if server goofs on extended replies
generator: Add struct nbd_extent in prep for 64-bit extents
block_status: Track 64-bit extents internally
block_status: Accept 64-bit extents during block status
api: Add [aio_]nbd_block_status_64
api: Add several functions for controlling extended headers
copy: Update nbdcopy to use 64-bit block status
dump: Update nbddump to use 64-bit block status
info: Expose extended-headers support through nbdinfo
info: Update nbdinfo --map to use 64-bit block status
examples: Update copy-libev to use 64-bit block status
ocaml: Add example for 64-bit extents
generator: Actually request extended headers
api: Add nbd_[aio_]opt_extended_headers()
interop: Add test of 64-bit block status
api: Add nbd_can_block_status_payload()
api: Add nbd_[aio_]block_status_filter()
docs/libnbd.pod | 18 +-
info/nbdinfo.pod | 21 +-
sh/nbdsh.pod | 2 +-
lib/internal.h | 41 +-
lib/nbd-protocol.h | 112 +++-
generator/API.mli | 1 +
generator/API.ml | 534 +++++++++++++++---
generator/C.ml | 24 +-
generator/GoLang.ml | 24 +
generator/Makefile.am | 1 +
generator/OCaml.ml | 23 +-
generator/Python.ml | 20 +-
generator/state_machine.ml | 50 +-
generator/states-issue-command.c | 33 +-
.../states-newstyle-opt-extended-headers.c | 110 ++++
generator/states-newstyle-opt-starttls.c | 7 +-
.../states-newstyle-opt-structured-reply.c | 3 +-
generator/states-newstyle.c | 3 +
generator/states-reply-simple.c | 4 +-
generator/states-reply-structured.c | 253 ++++++---
generator/states-reply.c | 69 ++-
lib/aio.c | 7 +-
lib/flags.c | 12 +
lib/handle.c | 25 +-
lib/opt.c | 44 ++
lib/rw.c | 250 +++++++-
python/t/110-defaults.py | 1 +
python/t/120-set-non-defaults.py | 2 +
python/t/465-block-status-64.py | 56 ++
ocaml/examples/Makefile.am | 1 +
ocaml/examples/extents64.ml | 42 ++
ocaml/helpers.c | 20 +
ocaml/nbd-c.h | 1 +
ocaml/tests/Makefile.am | 1 +
ocaml/tests/test_110_defaults.ml | 2 +
ocaml/tests/test_120_set_non_defaults.ml | 3 +
ocaml/tests/test_465_block_status_64.ml | 58 ++
tests/Makefile.am | 4 +
tests/meta-base-allocation.c | 104 +++-
tests/pwrite-extended.c | 112 ++++
examples/copy-libev.c | 21 +-
examples/server-flags.c | 7 +-
interop/Makefile.am | 18 +
interop/block-status-payload.c | 241 ++++++++
interop/block-status-payload.sh | 80 +++
interop/large-status.c | 186 ++++++
interop/large-status.sh | 49 ++
interop/opt-extended-headers.c | 153 +++++
interop/opt-extended-headers.sh | 29 +
.gitignore | 4 +
copy/nbd-ops.c | 22 +-
dump/dump.c | 27 +-
fuzzing/libnbd-fuzz-wrapper.c | 20 +-
golang/Makefile.am | 1 +
golang/handle.go | 6 +
golang/libnbd_110_defaults_test.go | 8 +
golang/libnbd_120_set_non_defaults_test.go | 12 +
golang/libnbd_465_block_status_64_test.go | 119 ++++
info/can.c | 14 +
info/info-can.sh | 30 +
info/info-packets.sh | 17 +-
info/main.c | 7 +-
info/map.c | 65 ++-
info/show.c | 9 +-
64 files changed, 2892 insertions(+), 351 deletions(-)
create mode 100644 generator/states-newstyle-opt-extended-headers.c
create mode 100644 python/t/465-block-status-64.py
create mode 100644 ocaml/examples/extents64.ml
create mode 100644 ocaml/tests/test_465_block_status_64.ml
create mode 100644 tests/pwrite-extended.c
create mode 100644 interop/block-status-payload.c
create mode 100755 interop/block-status-payload.sh
create mode 100644 interop/large-status.c
create mode 100755 interop/large-status.sh
create mode 100644 interop/opt-extended-headers.c
create mode 100755 interop/opt-extended-headers.sh
create mode 100644 golang/libnbd_465_block_status_64_test.go
base-commit: 17d0bc6a71bbc67f3d7707d129bec4acf7e7a382
--
2.40.1
1 year, 3 months
[PATCH v3 00/14] qemu patches for 64-bit NBD extensions
by Eric Blake
v2 was here:
https://lists.gnu.org/archive/html/qemu-devel/2022-11/msg02340.html
Since then:
- upstream NBD has accepted the extension on a branch; once multiple
implementations interoperate based on that spec, it will be promoted
to mainline (my plan: qemu with this series, libnbd nearly ready to
go, nbdkit a bit further out)
- rebase to block changes in meantime
- drop RFC patches for 64-bit NBD_CMD_READ (NBD spec did not take them)
- per upstream spec decision, extended headers now mandates use of
NBD_REPLY_TYPE_BLOCK_STATUS_EXT rather than server choice based on
reply size, which in turn required rearranging server patches a bit
- other changes that I noticed while testing with parallel changes
being added to libnbd (link to those patches to follow in the next
week or so)
Eric Blake (14):
nbd/client: Use smarter assert
nbd/client: Add safety check on chunk payload length
nbd/server: Prepare for alternate-size headers
nbd: Prepare for 64-bit request effect lengths
nbd: Add types for extended headers
nbd/server: Refactor handling of request payload
nbd/server: Refactor to pass full request around
nbd/server: Support 64-bit block status
nbd/server: Initial support for extended headers
nbd/client: Initial support for extended headers
nbd/client: Accept 64-bit block status chunks
nbd/client: Request extended headers during negotiation
nbd/server: Prepare for per-request filtering of BLOCK_STATUS
nbd/server: Add FLAG_PAYLOAD support to CMD_BLOCK_STATUS
docs/interop/nbd.txt | 1 +
include/block/nbd.h | 165 +++--
nbd/nbd-internal.h | 8 +-
block/nbd.c | 86 ++-
nbd/client-connection.c | 4 +-
nbd/client.c | 143 ++--
nbd/common.c | 10 +-
nbd/server.c | 653 ++++++++++++------
qemu-nbd.c | 4 +
block/trace-events | 1 +
nbd/trace-events | 11 +-
tests/qemu-iotests/223.out | 18 +-
tests/qemu-iotests/233.out | 5 +
tests/qemu-iotests/241.out | 3 +
tests/qemu-iotests/307.out | 15 +-
.../tests/nbd-qemu-allocation.out | 3 +-
16 files changed, 797 insertions(+), 333 deletions(-)
base-commit: 18b6727083acceac5d76ea0b8cb6f5cdef6858a7
--
2.40.1
1 year, 5 months
[PATCH libguestfs 1/2] ocaml/implicit_close test: collect all currently unreachable blocks
by Jürgen Hötzel
Fixes failing implice_close test on OCaml 5.
---
ocaml/t/guestfs_065_implicit_close.ml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ocaml/t/guestfs_065_implicit_close.ml b/ocaml/t/guestfs_065_implicit_close.ml
index 567e550b4..5e00c21ac 100644
--- a/ocaml/t/guestfs_065_implicit_close.ml
+++ b/ocaml/t/guestfs_065_implicit_close.ml
@@ -30,8 +30,8 @@ let () =
*)
(* This should cause the GC to close the handle. *)
-let () = Gc.compact ()
+let () = Gc.full_major ()
let () = assert (!close_invoked = 1)
-let () = Gc.compact ()
+let () = Gc.full_major ()
--
2.40.1
1 year, 5 months
[PATCH libguestfs 2/2] Only leave/enter blocking_section when OCaml lock is not held
by Jürgen Hötzel
Fixes deadlocks on OCaml5 when trying to get the lock that is already
held:
Fatal error during lock: Resource deadlock avoided
---
ocaml/guestfs-c.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ocaml/guestfs-c.c b/ocaml/guestfs-c.c
index 3888c9456..bcf8e6ab3 100644
--- a/ocaml/guestfs-c.c
+++ b/ocaml/guestfs-c.c
@@ -395,12 +395,16 @@ event_callback_wrapper (guestfs_h *g,
/* Ensure we are holding the GC lock before any GC operations are
* possible. (RHBZ#725824)
*/
- caml_leave_blocking_section ();
+ bool in_blocking_section = (caml_state == NULL);
+
+ if (in_blocking_section)
+ caml_leave_blocking_section ();
event_callback_wrapper_locked (g, data, event, event_handle, flags,
buf, buf_len, array, array_len);
- caml_enter_blocking_section ();
+ if (in_blocking_section)
+ caml_enter_blocking_section ();
}
value
--
2.40.1
1 year, 5 months
[libnbd PATCH] internal: Tweak use of attribute packed in union sbuf
by Eric Blake
While analyzing 'union sbuf' in preparation to add more members to the
union, I noticed several things related to __attribute__((packed))
that can be improved. It helps to note that that the bulk of the
members of 'union sbuf' are already marked packed structures from
nbd-protocol.h, where we don't need to repeat that annotation in
internal.h but where it does factor into sbuf alignment.
First, rather than open-coding the attribute name in internal.h (in
some places with inconsistent whitespace), we can reuse
NBD_ATTRIBUTE_PACKED already present from nbd-protocol.h.
Second, note that two of the union members are themselves substructs
with two parts: both sbuf.or and sbuf.sr need distinct storage for a
header (a packed structure) and a payload (a union of various items;
currently each member of both of those unions are already packed),
where the choice of union branch and overall size of the payload to be
read (if any) is determined by information in the header. Later
states then refer to information from both the header and payload, so
we need to keep the sub-structs (rather than hoisting the two parts of
the sub-struct into being directly-overlapping top-level members of
union sbuf proper). But because we don't know the payload size until
after the header is read, the state machine uses separate recv() calls
into the two parts of sbuf.or and sbuf.sr; and there is no specific
reason that the two reads need to occur into adjacent memory. Thus,
these two packed annotations buy us nothing at this layer and can be
safely elided.
Finally, there are benefits to naturally aligning uint64_t members,
whether or not hardware supports unaligned access. Even though we are
using attribute packed to match wire format (and some NBD messages do
not have any natural alignment), the judicious use of a non-packed
uint64_t member to various unions gives the compiler permission to
insert padding that is otherwise not possible when a packed struct
occurs immediately before a union containing only packed members. In
particular, with structured replies, it is worth ensuring that
sbuf.sr.payload.offset_data.offset falls on a 64-bit alignment.
Note that sbuf.or does not need this latter treatment (currently,
(sbuf.or.payload.export.exportsize is the only uint64_t in that
particular payload union, but does not occur at a natural alignment to
begin with); but it is also worth remembering that option negotiation
is not in the hot path the way sbuf.sr is.
Actually testing the alignment change from adding align_ members is
harder to do, especially without C11's <stdalign.h>, in part because
on 32-bit platforms where uint64_t is only 4-byte aligned (without gcc
-malign-double), there is no change to layout. But in my
investigation under gdb on x86_64, inserting the otherwise-unused
align_* members changed both offsetof(struct nbd_handle, sbuf) % 8 and
(offsetof(struct nbd_handle, sbuf.sr.payload) - offsetof(struct
nbd_handle, sbuf)) % 8 from 4 to 0, which is what I wanted.
Not touched here: gcc's -Wpacked says several (but not all) of our
structures in that file are already naturally aligned, where adding a
packed notation can actually cause slower code when embedding that
type in a larger structure (exactly what we're doing when combining
those structs into sbuf), when the compiler has to prepare for
unaligned access even if the struct would otherwise be aligned.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Fallout from review of the 64-bit v3 2/22 patch.
lib/internal.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lib/internal.h b/lib/internal.h
index b155681d..a8c49e16 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -212,6 +212,7 @@ struct nbd_handle {
* and commands.
*/
union {
+ uint64_t align_; /* Start sbuf on an 8-byte alignment where useful */
struct nbd_old_handshake old_handshake;
struct nbd_new_handshake new_handshake;
struct nbd_new_option option;
@@ -221,34 +222,35 @@ struct nbd_handle {
struct {
struct nbd_fixed_new_option_reply_server server;
char str[NBD_MAX_STRING * 2 + 1]; /* name, description, NUL */
- } __attribute__ ((packed)) server;
+ } NBD_ATTRIBUTE_PACKED server;
struct nbd_fixed_new_option_reply_info_export export;
struct nbd_fixed_new_option_reply_info_block_size block_size;
struct {
struct nbd_fixed_new_option_reply_info_name_or_desc info;
char str[NBD_MAX_STRING];
- } __attribute__ ((packed)) name_desc;
+ } NBD_ATTRIBUTE_PACKED name_desc;
struct {
struct nbd_fixed_new_option_reply_meta_context context;
char str[NBD_MAX_STRING];
- } __attribute__ ((packed)) context;
+ } NBD_ATTRIBUTE_PACKED context;
char err_msg[NBD_MAX_STRING];
} payload;
- } __attribute__ ((packed)) or;
+ } or;
struct nbd_export_name_option_reply export_name_reply;
struct nbd_simple_reply simple_reply;
struct {
struct nbd_structured_reply structured_reply;
union {
+ uint64_t align_; /* Start sr.payload on an 8-byte alignment */
struct nbd_structured_reply_offset_data offset_data;
struct nbd_structured_reply_offset_hole offset_hole;
struct {
struct nbd_structured_reply_error error;
char msg[NBD_MAX_STRING]; /* Common to all error types */
uint64_t offset; /* Only used for NBD_REPLY_TYPE_ERROR_OFFSET */
- } __attribute__ ((packed)) error;
+ } NBD_ATTRIBUTE_PACKED error;
} payload;
- } __attribute__ ((packed)) sr;
+ } sr;
uint16_t gflags;
uint32_t cflags;
uint32_t len;
--
2.40.1
1 year, 5 months
[libnbd PATCH] internal: s/handle/cookie/ to match NBD spec
by Eric Blake
Externally, we have been exposing the 64-bit opaque marker for each
NBD packet as the "cookie", because it was less confusing when
contrasted with our 'struct nbd_handle *' holding all libnbd state.
It also avoids confusion between the noun 'handle' as a way to
identify a packet and the verb 'handle' for reacting to things like
signals. Upstream NBD changed their spec to favor the name "cookie"
based on our recommendations[1], and so now we can get rid of our last
uses of the old name.
[1] https://github.com/NetworkBlockDevice/nbd/commit/ca4392eb2b
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
lib/nbd-protocol.h | 6 +++---
generator/states-issue-command.c | 6 +++---
generator/states-reply-simple.c | 2 +-
generator/states-reply.c | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/nbd-protocol.h b/lib/nbd-protocol.h
index 0217891e..50275dcd 100644
--- a/lib/nbd-protocol.h
+++ b/lib/nbd-protocol.h
@@ -193,7 +193,7 @@ struct nbd_request {
uint32_t magic; /* NBD_REQUEST_MAGIC. */
uint16_t flags; /* Request flags. */
uint16_t type; /* Request type. */
- uint64_t handle; /* Opaque handle. */
+ uint64_t cookie; /* Opaque handle. */
uint64_t offset; /* Request offset. */
uint32_t count; /* Request length. */
} NBD_ATTRIBUTE_PACKED;
@@ -202,7 +202,7 @@ struct nbd_request {
struct nbd_simple_reply {
uint32_t magic; /* NBD_SIMPLE_REPLY_MAGIC. */
uint32_t error; /* NBD_SUCCESS or one of NBD_E*. */
- uint64_t handle; /* Opaque handle. */
+ uint64_t cookie; /* Opaque handle. */
} NBD_ATTRIBUTE_PACKED;
/* Structured reply (server -> client). */
@@ -210,7 +210,7 @@ struct nbd_structured_reply {
uint32_t magic; /* NBD_STRUCTURED_REPLY_MAGIC. */
uint16_t flags; /* NBD_REPLY_FLAG_* */
uint16_t type; /* NBD_REPLY_TYPE_* */
- uint64_t handle; /* Opaque handle. */
+ uint64_t cookie; /* Opaque handle. */
uint32_t length; /* Length of payload which follows. */
} NBD_ATTRIBUTE_PACKED;
diff --git a/generator/states-issue-command.c b/generator/states-issue-command.c
index 111e131c..30721946 100644
--- a/generator/states-issue-command.c
+++ b/generator/states-issue-command.c
@@ -44,7 +44,7 @@ ISSUE_COMMAND.START:
h->request.magic = htobe32 (NBD_REQUEST_MAGIC);
h->request.flags = htobe16 (cmd->flags);
h->request.type = htobe16 (cmd->type);
- h->request.handle = htobe64 (cmd->cookie);
+ h->request.cookie = htobe64 (cmd->cookie);
h->request.offset = htobe64 (cmd->offset);
h->request.count = htobe32 (cmd->count);
h->chunks_sent++;
@@ -74,7 +74,7 @@ ISSUE_COMMAND.PREPARE_WRITE_PAYLOAD:
assert (h->cmds_to_issue != NULL);
cmd = h->cmds_to_issue;
- assert (cmd->cookie == be64toh (h->request.handle));
+ assert (cmd->cookie == be64toh (h->request.cookie));
if (cmd->type == NBD_CMD_WRITE) {
h->wbuf = cmd->data;
h->wlen = cmd->count;
@@ -120,7 +120,7 @@ ISSUE_COMMAND.FINISH:
assert (!h->wlen);
assert (h->cmds_to_issue != NULL);
cmd = h->cmds_to_issue;
- assert (cmd->cookie == be64toh (h->request.handle));
+ assert (cmd->cookie == be64toh (h->request.cookie));
h->cmds_to_issue = cmd->next;
if (h->cmds_to_issue_tail == cmd)
h->cmds_to_issue_tail = NULL;
diff --git a/generator/states-reply-simple.c b/generator/states-reply-simple.c
index 8fd9f62a..19be5418 100644
--- a/generator/states-reply-simple.c
+++ b/generator/states-reply-simple.c
@@ -39,7 +39,7 @@ REPLY.SIMPLE_REPLY.START:
if (error || h->structured_replies)
SET_NEXT_STATE (%^FINISH_COMMAND);
else {
- uint64_t cookie = be64toh (h->sbuf.simple_reply.handle);
+ uint64_t cookie = be64toh (h->sbuf.simple_reply.cookie);
SET_NEXT_STATE (%.DEAD);
set_error (EPROTO,
"no matching cookie %" PRIu64 " found for server reply, "
diff --git a/generator/states-reply.c b/generator/states-reply.c
index f7888154..511e5cb1 100644
--- a/generator/states-reply.c
+++ b/generator/states-reply.c
@@ -138,7 +138,7 @@ REPLY.CHECK_SIMPLE_OR_STRUCTURED_REPLY:
* handle (our cookie) is stored at the same offset.
*/
h->chunks_received++;
- cookie = be64toh (h->sbuf.simple_reply.handle);
+ cookie = be64toh (h->sbuf.simple_reply.cookie);
/* Find the command amongst the commands in flight. If the server sends
* a reply for an unknown cookie, FINISH will diagnose that later.
*/
@@ -157,7 +157,7 @@ REPLY.FINISH_COMMAND:
/* NB: This works for both simple and structured replies because the
* handle (our cookie) is stored at the same offset.
*/
- cookie = be64toh (h->sbuf.simple_reply.handle);
+ cookie = be64toh (h->sbuf.simple_reply.cookie);
/* Find the command amongst the commands in flight. */
for (cmd = h->cmds_in_flight, prev_cmd = NULL;
cmd != NULL;
--
2.40.1
1 year, 5 months
[libnbd PATCH] maint: Drop useless casts
by Eric Blake
While reviewing the previous whitespace-only patch, I noticed several
casts that are semantically unnecessary in C:
- converting pointers to and from void* does not need a cast except
for function pointers or when also casting away const (different
from C++ where casts to or from void* are required for type safety);
includes cases like python PyCapsule code which uses void*
- casting away const on a string literal (in C, string literals are
typed 'char *', different from C++ where they are 'const char *';
that said, C says it is still undefined behavior to modify their
contents, so string literals should generally be only assigned to
'const char *' variables or passed to functions that promise not to
modify contents); includes cases like ocaml's struct
custom_operations using 'const char *' as its member type (where
casting away const just to re-add it is pointless)
- casts used to document what would otherwise be implicit type
conversions when assigning to integers of a different type or
passing function parameters not through varargs. While this can be
useful for documentation purposes, it can also mask bugs when the
cast uses the wrong intermediate type only to be implicitly
converted back to the destination type, and it is often easier to
use optional compiler warning flags to catch instances of unintended
truncation or sign extension by implicit conversions.
Minimizing semantically unneeded casts lets the remaining casts stand
out for why they are necessary: casting aways const, casts between
pointer aliases (such as struct sockaddr*, char* vs unsigned char*,
...), and scalars passed through vargs in printf-like functions.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
generator/Python.ml | 2 +-
generator/states-connect-socket-activation.c | 2 +-
generator/states-issue-command.c | 2 +-
lib/utils.c | 4 ++--
python/handle.c | 2 +-
ocaml/nbd-c.h | 6 +++---
tests/opt-set-meta.c | 2 +-
copy/main.c | 6 +++---
fuse/nbdfuse.c | 4 ++--
fuse/operations.c | 2 +-
ublk/nbdublk.c | 4 ++--
11 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/generator/Python.ml b/generator/Python.ml
index b73f9782..c81878de 100644
--- a/generator/Python.ml
+++ b/generator/Python.ml
@@ -49,7 +49,7 @@ let
{
assert (obj);
assert (obj != Py_None);
- return (struct nbd_handle *)PyCapsule_GetPointer(obj, \"nbd_handle\");
+ return PyCapsule_GetPointer(obj, \"nbd_handle\");
}
/* nbd.Error exception. */
diff --git a/generator/states-connect-socket-activation.c b/generator/states-connect-socket-activation.c
index 98a39c0e..40a3528c 100644
--- a/generator/states-connect-socket-activation.c
+++ b/generator/states-connect-socket-activation.c
@@ -294,7 +294,7 @@ CONNECT_SA.START:
char buf[32];
const char *v =
- nbd_internal_fork_safe_itoa ((long)getpid (), buf, sizeof buf);
+ nbd_internal_fork_safe_itoa (getpid (), buf, sizeof buf);
NBD_INTERNAL_FORK_SAFE_ASSERT (strlen (v) <= sact_var[pid_ofs].value_len);
strcpy (env.ptr[pid_ofs] + sact_var[pid_ofs].prefix_len, v);
diff --git a/generator/states-issue-command.c b/generator/states-issue-command.c
index 34ef4652..111e131c 100644
--- a/generator/states-issue-command.c
+++ b/generator/states-issue-command.c
@@ -46,7 +46,7 @@ ISSUE_COMMAND.START:
h->request.type = htobe16 (cmd->type);
h->request.handle = htobe64 (cmd->cookie);
h->request.offset = htobe64 (cmd->offset);
- h->request.count = htobe32 ((uint32_t)cmd->count);
+ h->request.count = htobe32 (cmd->count);
h->chunks_sent++;
h->wbuf = &h->request;
h->wlen = sizeof (h->request);
diff --git a/lib/utils.c b/lib/utils.c
index e3e13cdd..5df5ae51 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -154,7 +154,7 @@ nbd_internal_set_querylist (struct nbd_handle *h, char **queries)
const char *
nbd_internal_fork_safe_itoa (long v, char *buf, size_t bufsize)
{
- unsigned long uv = (unsigned long)v;
+ unsigned long uv = v;
size_t i = bufsize - 1;
bool neg = false;
@@ -282,7 +282,7 @@ nbd_internal_fork_safe_perror (const char *s)
#endif
#endif
if (!m)
- m = nbd_internal_fork_safe_itoa ((long)errno, buf, sizeof buf);
+ m = nbd_internal_fork_safe_itoa (errno, buf, sizeof buf);
xwritel (STDERR_FILENO, s, ": ", m, "\n", (char *)NULL);
/* Restore original errno in case it was disturbed by the system
diff --git a/python/handle.c b/python/handle.c
index 8ff6ba81..548f2dfe 100644
--- a/python/handle.c
+++ b/python/handle.c
@@ -46,7 +46,7 @@ static inline PyObject *
put_handle (struct nbd_handle *h)
{
assert (h);
- return PyCapsule_New ((void *)h, "nbd_handle", NULL);
+ return PyCapsule_New (h, "nbd_handle", NULL);
}
PyObject *
diff --git a/ocaml/nbd-c.h b/ocaml/nbd-c.h
index 0cbe36d1..e3abb912 100644
--- a/ocaml/nbd-c.h
+++ b/ocaml/nbd-c.h
@@ -49,7 +49,7 @@ static inline value
caml_alloc_initialized_string (mlsize_t len, const char *p)
{
value sv = caml_alloc_string (len);
- memcpy ((char *)String_val (sv), p, len);
+ memcpy (String_val (sv), p, len);
return sv;
}
#endif
@@ -70,7 +70,7 @@ extern void nbd_internal_ocaml_exception_in_wrapper (const char *, value);
#define NBD_val(v) (*((struct nbd_handle **)Data_custom_val (v)))
static struct custom_operations libnbd_custom_operations = {
- (char *)"libnbd_custom_operations",
+ "libnbd_custom_operations",
nbd_internal_ocaml_handle_finalize,
custom_compare_default,
custom_hash_default,
@@ -110,7 +110,7 @@ struct nbd_buffer {
#define NBD_buffer_val(v) ((struct nbd_buffer *)Data_custom_val (v))
static struct custom_operations nbd_buffer_custom_operations = {
- (char *)"nbd_buffer_custom_operations",
+ "nbd_buffer_custom_operations",
nbd_internal_ocaml_buffer_finalize,
custom_compare_default,
custom_hash_default,
diff --git a/tests/opt-set-meta.c b/tests/opt-set-meta.c
index 1bd60a9c..06f503af 100644
--- a/tests/opt-set-meta.c
+++ b/tests/opt-set-meta.c
@@ -219,7 +219,7 @@ main (int argc, char *argv[])
* or newer with its --no-sr kill switch.
*/
requires ("nbdkit --no-sr --help");
- args[ARRAY_SIZE (args) - 2] = (char *)"--no-sr";
+ args[ARRAY_SIZE (args) - 2] = "--no-sr";
nbd = nbd_create ();
if (nbd == NULL ||
nbd_set_opt_mode (nbd, true) == -1 ||
diff --git a/copy/main.c b/copy/main.c
index 391c0c4f..9449440e 100644
--- a/copy/main.c
+++ b/copy/main.c
@@ -371,7 +371,7 @@ main (int argc, char *argv[])
#else
t = 1;
#endif
- threads = (unsigned)t;
+ threads = t;
}
if (synchronous)
@@ -534,7 +534,7 @@ open_local (const char *filename, direction d)
}
if (S_ISREG (stat.st_mode)) /* Regular file. */
return file_create (filename, fd,
- stat.st_size, (uint64_t)stat.st_blksize, false, d);
+ stat.st_size, stat.st_blksize, false, d);
else if (S_ISBLK (stat.st_mode)) { /* Block device. */
unsigned int blkioopt;
@@ -549,7 +549,7 @@ open_local (const char *filename, direction d)
#endif
return file_create (filename, fd,
- stat.st_size, (uint64_t)blkioopt, true, d);
+ stat.st_size, blkioopt, true, d);
}
else { /* Probably stdin/stdout, a pipe or a socket. */
synchronous = true; /* Force synchronous mode for pipes. */
diff --git a/fuse/nbdfuse.c b/fuse/nbdfuse.c
index 491f6db8..35d5ffac 100644
--- a/fuse/nbdfuse.c
+++ b/fuse/nbdfuse.c
@@ -415,7 +415,7 @@ main (int argc, char *argv[])
handles_append (&nbd, h); /* reserved above, so can't fail */
}
}
- connections = (unsigned)nbd.len;
+ connections = nbd.len;
if (verbose)
fprintf (stderr, "nbdfuse: connections=%u\n", connections);
@@ -424,7 +424,7 @@ main (int argc, char *argv[])
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
- size = (uint64_t)ssize;
+ size = ssize;
/* If the remote NBD server is readonly, then act as if the '-r'
* flag was given on the nbdfuse command line.
diff --git a/fuse/operations.c b/fuse/operations.c
index 2d0634dc..e487d150 100644
--- a/fuse/operations.c
+++ b/fuse/operations.c
@@ -396,7 +396,7 @@ nbdfuse_read (const char *path, char *buf,
CHECK_NBD_ASYNC_ERROR (nbd_aio_pread (h, buf, count, offset, cb, 0));
- return (int)count;
+ return count;
}
static int
diff --git a/ublk/nbdublk.c b/ublk/nbdublk.c
index b85ac609..2f097f3e 100644
--- a/ublk/nbdublk.c
+++ b/ublk/nbdublk.c
@@ -347,7 +347,7 @@ main (int argc, char *argv[])
handles_append (&nbd, h); /* reserved above, so can't fail */
}
}
- connections = (unsigned)nbd.len;
+ connections = nbd.len;
/* Get the size and preferred block sizes. */
rs = nbd_get_size (nbd.ptr[0]);
@@ -355,7 +355,7 @@ main (int argc, char *argv[])
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
- size = (uint64_t)rs;
+ size = rs;
rs = nbd_get_block_size (nbd.ptr[0], LIBNBD_SIZE_MAXIMUM);
if (rs <= 0 || rs > 64 * 1024 * 1024)
--
2.40.1
1 year, 6 months
[libnbd PATCH] maint: pick consistent spacing style for casts
by Eric Blake
We are inconsistent on whether a cast operator should be separated
from its argument by a space. As a unary prefix operator, casts bind
with relatively tight precedence, where only postfix operations
(including function calls) come higher. We generally don't use a
space after other prefix operators (*, &, ~, and unary - tend to not
be followed by space; we are less consistent on !, but that would be a
separate patch).
Furthermore, we've already decided (in commit b5101fbc) that we prefer
spaces before function invocations. At the time, discussion on the
list[1] pointed out that thanks to the complexity of C with its
context-sensitive parsing needing to know whether an identifier is a
type name, you would be able to tell the difference between a
2-argument function call with two parameters through a function
pointer (or intentional function-like macro suppression):
(foo) (bar, baz)
from the (admittedly rare) application of a cast operator to the
results of a comma operator:
(foo)(bar, baz)
if we consistently avoid spaces after casts.
Determining cast operators is not always trivial, but the regex used
below seems to have a pretty low false positive rate (lines it selects
usually are casts and not in a comment line), and can be modified by
removing the space to see where we already had casts without a
space. (Obviously, I can't tell how many false negatives there are of
casts I missed out on). While this changes more lines than would be
done by instead always using a space in a cast, it is still manageable
to do a bulk change.
$ git grep '\(_t\|int\|long\|signed\|char\|\*\)) [a-zA-Z0-9&"]' -- \
'**/*.[hc]' '**/*.ml' | grep -v '^ */\?\*'
'git show -w' shows that this change is whitespace only.
[1] https://listman.redhat.com/archives/libguestfs/2023-February/030771.html
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
configure.ac | 6 ++--
common/utils/vector.h | 4 +--
generator/OCaml.ml | 4 +--
generator/Python.ml | 4 +--
generator/states-connect-socket-activation.c | 4 +--
generator/states-connect.c | 2 +-
generator/states-issue-command.c | 2 +-
generator/states-newstyle.c | 2 +-
generator/states-oldstyle.c | 2 +-
generator/states-reply-structured.c | 14 ++++----
generator/states-reply.c | 2 +-
generator/states.c | 4 +--
lib/crypto.c | 6 ++--
lib/rw.c | 2 +-
lib/uri.c | 10 +++---
lib/utils.c | 4 +--
common/utils/test-vector.c | 4 +--
python/handle.c | 4 +--
python/utils.c | 2 +-
ocaml/nbd-c.h | 6 ++--
tests/aio-connect-port.c | 2 +-
tests/aio-connect.c | 2 +-
tests/errors-bad-cookie.c | 2 +-
tests/errors-client-oversize.c | 2 +-
tests/errors-client-unadvertised-cmd.c | 2 +-
tests/errors-client-unaligned.c | 2 +-
tests/errors-client-unknown-flags.c | 2 +-
tests/errors-client-zerosize.c | 2 +-
tests/errors-connect-null.c | 2 +-
tests/errors-connect-twice.c | 4 +--
tests/errors-multiple-disconnects.c | 2 +-
tests/errors-not-negotiating.c | 2 +-
tests/errors-notify-not-blocked.c | 2 +-
tests/errors-pread-structured.c | 2 +-
tests/errors-server-invalid-offset.c | 2 +-
tests/errors-server-oversize.c | 2 +-
tests/errors-server-unadvertised-cmd.c | 2 +-
tests/errors-server-unaligned.c | 2 +-
tests/errors-server-unknown-flags.c | 2 +-
tests/errors-server-zerosize.c | 2 +-
tests/opt-set-meta.c | 2 +-
tests/opt-starttls.c | 4 +--
tests/opt-structured-twice.c | 2 +-
tests/pread-initialize.c | 2 +-
tests/private-data.c | 4 +--
tests/server-death.c | 2 +-
tests/shutdown-flags.c | 2 +-
examples/glib-main-loop.c | 36 ++++++++++----------
examples/open-qcow2.c | 2 +-
interop/list-exports.c | 2 +-
copy/file-ops.c | 6 ++--
copy/main.c | 10 +++---
copy/nbd-ops.c | 36 ++++++++++----------
copy/pipe-ops.c | 8 ++---
dump/dump.c | 2 +-
fuse/nbdfuse.c | 8 ++---
fuse/operations.c | 10 +++---
ublk/nbdublk.c | 4 +--
ublk/tgt.c | 4 +--
59 files changed, 138 insertions(+), 138 deletions(-)
diff --git a/configure.ac b/configure.ac
index 30348ea9..0a9e4d79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -456,7 +456,7 @@ AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
AC_MSG_CHECKING([for caml_alloc_custom_mem])
cat >conftest.c <<'EOF'
#include <caml/custom.h>
-int main () { char *p = (void *) caml_alloc_custom_mem; return 0; }
+int main () { char *p = (void *)caml_alloc_custom_mem; return 0; }
EOF
AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[
AC_MSG_RESULT([yes])
@@ -474,7 +474,7 @@ AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
AC_MSG_CHECKING([for caml_alloc_initialized_string])
cat >conftest.c <<'EOF'
#include <caml/alloc.h>
-int main () { char *p = (void *) caml_alloc_initialized_string; return 0; }
+int main () { char *p = (void *)caml_alloc_initialized_string; return 0; }
EOF
AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[
AC_MSG_RESULT([yes])
@@ -492,7 +492,7 @@ AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
AC_MSG_CHECKING([for caml_unix_get_sockaddr])
cat >conftest.c <<'EOF'
#include <caml/socketaddr.h>
-int main () { char *p = (void *) caml_unix_get_sockaddr; return 0; }
+int main () { char *p = (void *)caml_unix_get_sockaddr; return 0; }
EOF
AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[
AC_MSG_RESULT([yes])
diff --git a/common/utils/vector.h b/common/utils/vector.h
index 7337d268..50cad1d0 100644
--- a/common/utils/vector.h
+++ b/common/utils/vector.h
@@ -173,7 +173,7 @@
name##_sort (name *v, \
int (*compare) (const type *p1, const type *p2)) \
{ \
- qsort (v->ptr, v->len, sizeof (type), (void *) compare); \
+ qsort (v->ptr, v->len, sizeof (type), (void *)compare); \
} \
\
/* Search for an exactly matching element in the vector using a \
@@ -184,7 +184,7 @@
int (*compare) (const void *key, const type *v)) \
{ \
return bsearch (key, v->ptr, v->len, sizeof (type), \
- (void *) compare); \
+ (void *)compare); \
} \
\
/* Make a new vector with the same elements. */ \
diff --git a/generator/OCaml.ml b/generator/OCaml.ml
index 300c8a70..edb81f25 100644
--- a/generator/OCaml.ml
+++ b/generator/OCaml.ml
@@ -710,12 +710,12 @@ let
pr " size_t %s = Int_val (%sv);\n" n n
| SockAddrAndLen (n, len) ->
pr " struct sockaddr_storage %s_storage;\n" n;
- pr " struct sockaddr *%s = (struct sockaddr *) &%s_storage;\n" n n;
+ pr " struct sockaddr *%s = (struct sockaddr *)&%s_storage;\n" n n;
pr " socklen_t %s;\n" len;
pr " nbd_internal_unix_sockaddr_to_sa (%sv, &%s_storage, &%s);\n"
n n len
| StringList n ->
- pr " char **%s = (char **) nbd_internal_ocaml_string_list (%sv);\n" n n
+ pr " char **%s = (char **)nbd_internal_ocaml_string_list (%sv);\n" n n
| UInt n | UIntPtr n ->
pr " unsigned %s = Int_val (%sv);\n" n n
| UInt32 n ->
diff --git a/generator/Python.ml b/generator/Python.ml
index c146f04f..b73f9782 100644
--- a/generator/Python.ml
+++ b/generator/Python.ml
@@ -49,7 +49,7 @@ let
{
assert (obj);
assert (obj != Py_None);
- return (struct nbd_handle *) PyCapsule_GetPointer(obj, \"nbd_handle\");
+ return (struct nbd_handle *)PyCapsule_GetPointer(obj, \"nbd_handle\");
}
/* nbd.Error exception. */
@@ -370,7 +370,7 @@ let
| SizeT n -> "n", sprintf "&%s" n, sprintf "(size_t)%s" n
| SockAddrAndLen (n, _) ->
"O", sprintf "&%s" n,
- sprintf "(struct sockaddr *) &%s_sa, %s_len" n n
+ sprintf "(struct sockaddr *)&%s_sa, %s_len" n n
| String n -> "s", sprintf "&%s" n, n
| StringList n -> "O", sprintf "&py_%s" n, n
| UInt n | UIntPtr n -> "I", sprintf "&%s" n, n
diff --git a/generator/states-connect-socket-activation.c b/generator/states-connect-socket-activation.c
index b57d5d00..98a39c0e 100644
--- a/generator/states-connect-socket-activation.c
+++ b/generator/states-connect-socket-activation.c
@@ -224,7 +224,7 @@ CONNECT_SA.START:
addr.sun_family = AF_UNIX;
memcpy (addr.sun_path, sockpath, strlen (sockpath) + 1);
- if (bind (s, (struct sockaddr *) &addr, sizeof addr) == -1) {
+ if (bind (s, (struct sockaddr *)&addr, sizeof addr) == -1) {
set_error (errno, "bind: %s", sockpath);
goto close_socket;
}
@@ -294,7 +294,7 @@ CONNECT_SA.START:
char buf[32];
const char *v =
- nbd_internal_fork_safe_itoa ((long) getpid (), buf, sizeof buf);
+ nbd_internal_fork_safe_itoa ((long)getpid (), buf, sizeof buf);
NBD_INTERNAL_FORK_SAFE_ASSERT (strlen (v) <= sact_var[pid_ofs].value_len);
strcpy (env.ptr[pid_ofs] + sact_var[pid_ofs].prefix_len, v);
diff --git a/generator/states-connect.c b/generator/states-connect.c
index 65a68003..98d9f945 100644
--- a/generator/states-connect.c
+++ b/generator/states-connect.c
@@ -84,7 +84,7 @@ CONNECT.START:
disable_nagle (fd);
disable_sigpipe (fd);
- r = connect (fd, (struct sockaddr *) &h->connaddr, h->connaddrlen);
+ r = connect (fd, (struct sockaddr *)&h->connaddr, h->connaddrlen);
if (r == 0 || (r == -1 && errno == EINPROGRESS))
return 0;
assert (r == -1);
diff --git a/generator/states-issue-command.c b/generator/states-issue-command.c
index a1458c6d..34ef4652 100644
--- a/generator/states-issue-command.c
+++ b/generator/states-issue-command.c
@@ -46,7 +46,7 @@ ISSUE_COMMAND.START:
h->request.type = htobe16 (cmd->type);
h->request.handle = htobe64 (cmd->cookie);
h->request.offset = htobe64 (cmd->offset);
- h->request.count = htobe32 ((uint32_t) cmd->count);
+ h->request.count = htobe32 ((uint32_t)cmd->count);
h->chunks_sent++;
h->wbuf = &h->request;
h->wlen = sizeof (h->request);
diff --git a/generator/states-newstyle.c b/generator/states-newstyle.c
index 3bd17c33..ad5bbf72 100644
--- a/generator/states-newstyle.c
+++ b/generator/states-newstyle.c
@@ -102,7 +102,7 @@ handle_reply_error (struct nbd_handle *h)
}
if (len > 0)
- debug (h, "handshake: server error message: %.*s", (int) len,
+ debug (h, "handshake: server error message: %.*s", (int)len,
h->sbuf.or.payload.err_msg);
return 0;
diff --git a/generator/states-oldstyle.c b/generator/states-oldstyle.c
index c9635636..f1be5df0 100644
--- a/generator/states-oldstyle.c
+++ b/generator/states-oldstyle.c
@@ -25,7 +25,7 @@ OLDSTYLE.START:
*/
h->rbuf = &h->sbuf.old_handshake;
h->rlen = sizeof h->sbuf.old_handshake;
- h->rbuf = (char *) h->rbuf + 16;
+ h->rbuf = (char *)h->rbuf + 16;
h->rlen -= 16;
SET_NEXT_STATE (%RECV_REMAINING);
return 0;
diff --git a/generator/states-reply-structured.c b/generator/states-reply-structured.c
index 0788fb03..5aca7262 100644
--- a/generator/states-reply-structured.c
+++ b/generator/states-reply-structured.c
@@ -49,7 +49,7 @@ REPLY.STRUCTURED_REPLY.START:
* so read the remaining part.
*/
h->rbuf = &h->sbuf;
- h->rbuf = (char *) h->rbuf + sizeof h->sbuf.simple_reply;
+ h->rbuf = (char *)h->rbuf + sizeof h->sbuf.simple_reply;
h->rlen = sizeof h->sbuf.sr.structured_reply;
h->rlen -= sizeof h->sbuf.simple_reply;
SET_NEXT_STATE (%RECV_REMAINING);
@@ -223,7 +223,7 @@ REPLY.STRUCTURED_REPLY.RECV_ERROR_MESSAGE:
length -= sizeof h->sbuf.sr.payload.error.error + msglen;
if (msglen)
- debug (h, "structured error server message: %.*s", (int) msglen,
+ debug (h, "structured error server message: %.*s", (int)msglen,
h->sbuf.sr.payload.error.msg);
/* Special case two specific errors; silently ignore tail for all others */
@@ -286,7 +286,7 @@ REPLY.STRUCTURED_REPLY.RECV_ERROR_TAIL:
* without setting errno, then use the server's error below.
*/
if (CALL_CALLBACK (cmd->cb.fn.chunk,
- (char *) cmd->data + (offset - cmd->offset),
+ (char *)cmd->data + (offset - cmd->offset),
0, offset, LIBNBD_READ_ERROR,
&scratch) == -1)
if (cmd->error == 0)
@@ -337,7 +337,7 @@ REPLY.STRUCTURED_REPLY.RECV_OFFSET_DATA:
offset -= cmd->offset;
/* Set up to receive the data directly to the user buffer. */
- h->rbuf = (char *) cmd->data + offset;
+ h->rbuf = (char *)cmd->data + offset;
h->rlen = length;
SET_NEXT_STATE (%RECV_OFFSET_DATA_DATA);
}
@@ -363,7 +363,7 @@ REPLY.STRUCTURED_REPLY.RECV_OFFSET_DATA_DATA:
int error = cmd->error;
if (CALL_CALLBACK (cmd->cb.fn.chunk,
- (char *) cmd->data + (offset - cmd->offset),
+ (char *)cmd->data + (offset - cmd->offset),
length - sizeof offset, offset,
LIBNBD_READ_DATA, &error) == -1)
if (cmd->error == 0)
@@ -408,12 +408,12 @@ REPLY.STRUCTURED_REPLY.RECV_OFFSET_HOLE:
* them as an extension, and this works even when length == 0.
*/
if (!cmd->initialized)
- memset ((char *) cmd->data + offset, 0, length);
+ memset ((char *)cmd->data + offset, 0, length);
if (CALLBACK_IS_NOT_NULL (cmd->cb.fn.chunk)) {
int error = cmd->error;
if (CALL_CALLBACK (cmd->cb.fn.chunk,
- (char *) cmd->data + offset, length,
+ (char *)cmd->data + offset, length,
cmd->offset + offset,
LIBNBD_READ_HOLE, &error) == -1)
if (cmd->error == 0)
diff --git a/generator/states-reply.c b/generator/states-reply.c
index 010d108b..f7888154 100644
--- a/generator/states-reply.c
+++ b/generator/states-reply.c
@@ -97,7 +97,7 @@ REPLY.START:
#endif
h->bytes_received += r;
- h->rbuf = (char *) h->rbuf + r;
+ h->rbuf = (char *)h->rbuf + r;
h->rlen -= r;
SET_NEXT_STATE (%RECV_REPLY);
return 0;
diff --git a/generator/states.c b/generator/states.c
index 836862ea..425fa62f 100644
--- a/generator/states.c
+++ b/generator/states.c
@@ -91,7 +91,7 @@ recv_into_rbuf (struct nbd_handle *h)
#endif
h->bytes_received += r;
if (h->rbuf)
- h->rbuf = (char *) h->rbuf + r;
+ h->rbuf = (char *)h->rbuf + r;
h->rlen -= r;
if (h->rlen == 0)
return 0; /* move to next state */
@@ -114,7 +114,7 @@ send_from_wbuf (struct nbd_handle *h)
return -1;
}
h->bytes_sent += r;
- h->wbuf = (char *) h->wbuf + r;
+ h->wbuf = (char *)h->wbuf + r;
h->wlen -= r;
if (h->wlen == 0)
goto next_state;
diff --git a/lib/crypto.c b/lib/crypto.c
index d43eeb4c..22a1cfa5 100644
--- a/lib/crypto.c
+++ b/lib/crypto.c
@@ -307,7 +307,7 @@ lookup_key (const char *pskfile, const char *username,
if (r > ulen+1 &&
strncmp (line, username, ulen) == 0 &&
line[ulen] == ':') {
- key->data = (unsigned char *) strdup (&line[ulen+1]);
+ key->data = (unsigned char *)strdup (&line[ulen+1]);
if (key->data == NULL) {
set_error (errno, "strdup");
goto error;
@@ -712,7 +712,7 @@ nbd_internal_crypto_handshake (struct nbd_handle *h)
in = gnutls_handshake_get_last_in (session);
out = gnutls_handshake_get_last_out (session);
set_error (0, "gnutls_handshake: %s (%d/%d)",
- gnutls_strerror (err), (int) in, (int) out);
+ gnutls_strerror (err), (int)in, (int)out);
return -1;
}
@@ -742,7 +742,7 @@ nbd_internal_crypto_debug_tls_enabled (struct nbd_handle *h)
case GNUTLS_KTLS_SEND: ktls_status = "enabled send only"; break;
case GNUTLS_KTLS_DUPLEX: ktls_status = "enabled"; break;
default:
- if ((int) ktls_enabled == 0)
+ if ((int)ktls_enabled == 0)
ktls_status = "disabled";
else
ktls_status = "unknown";
diff --git a/lib/rw.c b/lib/rw.c
index a8d9e66c..3dc3499e 100644
--- a/lib/rw.c
+++ b/lib/rw.c
@@ -361,7 +361,7 @@ nbd_unlocked_aio_pwrite (struct nbd_handle *h, const void *buf,
SET_CALLBACK_TO_NULL (*completion);
return nbd_internal_command_common (h, flags, NBD_CMD_WRITE, offset, count,
- ENOSPC, (void *) buf, &cb);
+ ENOSPC, (void *)buf, &cb);
}
int64_t
diff --git a/lib/uri.c b/lib/uri.c
index f9fde455..0c8e87cf 100644
--- a/lib/uri.c
+++ b/lib/uri.c
@@ -376,7 +376,7 @@ nbd_unlocked_aio_connect_uri (struct nbd_handle *h, const char *raw_uri)
* uri->port > 0. This prevents us from using certain very large
* port numbers, but that's not an issue that matters in practice.
*/
- svm_port = uri->port > 0 ? (uint32_t) uri->port : 10809;
+ svm_port = uri->port > 0 ? (uint32_t)uri->port : 10809;
if (nbd_unlocked_aio_connect_vsock (h, cid, svm_port) == -1)
goto cleanup;
@@ -451,7 +451,7 @@ nbd_unlocked_get_uri (struct nbd_handle *h)
char serv[NI_MAXSERV];
uri.scheme = using_tls ? "nbds" : "nbd";
- err = getnameinfo ((struct sockaddr *) &h->connaddr, h->connaddrlen,
+ err = getnameinfo ((struct sockaddr *)&h->connaddr, h->connaddrlen,
host, sizeof host, serv, sizeof serv,
NI_NUMERICHOST | NI_NUMERICSERV);
if (err != 0) {
@@ -471,7 +471,7 @@ nbd_unlocked_get_uri (struct nbd_handle *h)
}
case AF_UNIX: {
- struct sockaddr_un *sun = (struct sockaddr_un *) &h->connaddr;
+ struct sockaddr_un *sun = (struct sockaddr_un *)&h->connaddr;
if (sun->sun_path[0] == '\0') {
/* Unix domain sockets in the abstract namespace are in theory
@@ -495,7 +495,7 @@ nbd_unlocked_get_uri (struct nbd_handle *h)
#if HAVE_STRUCT_SOCKADDR_VM
case AF_VSOCK: {
- struct sockaddr_vm *svm = (struct sockaddr_vm *) &h->connaddr;
+ struct sockaddr_vm *svm = (struct sockaddr_vm *)&h->connaddr;
uri.scheme = using_tls ? "nbds+vsock" : "nbd+vsock";
if (asprintf (&server, "%u:%u", svm->svm_cid, svm->svm_port) == -1) {
@@ -543,7 +543,7 @@ nbd_unlocked_get_uri (struct nbd_handle *h)
uri.query_raw = query_params;
/* Construct the final URI and return it. */
- ret = (char *) xmlSaveUri (&uri);
+ ret = (char *)xmlSaveUri (&uri);
if (ret == NULL)
set_error (errno, "xmlSaveUri failed");
out:
diff --git a/lib/utils.c b/lib/utils.c
index bce38df8..e3e13cdd 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -154,7 +154,7 @@ nbd_internal_set_querylist (struct nbd_handle *h, char **queries)
const char *
nbd_internal_fork_safe_itoa (long v, char *buf, size_t bufsize)
{
- unsigned long uv = (unsigned long) v;
+ unsigned long uv = (unsigned long)v;
size_t i = bufsize - 1;
bool neg = false;
@@ -282,7 +282,7 @@ nbd_internal_fork_safe_perror (const char *s)
#endif
#endif
if (!m)
- m = nbd_internal_fork_safe_itoa ((long) errno, buf, sizeof buf);
+ m = nbd_internal_fork_safe_itoa ((long)errno, buf, sizeof buf);
xwritel (STDERR_FILENO, s, ": ", m, "\n", (char *)NULL);
/* Restore original errno in case it was disturbed by the system
diff --git a/common/utils/test-vector.c b/common/utils/test-vector.c
index 26ad5136..399f4f26 100644
--- a/common/utils/test-vector.c
+++ b/common/utils/test-vector.c
@@ -82,10 +82,10 @@ test_int64_vector (void)
assert (v.ptr[1] == 2);
tmp = 10;
- p = int64_vector_search (&v, &tmp, (void*) compare);
+ p = int64_vector_search (&v, &tmp, (void *)compare);
assert (p == NULL);
tmp = 8;
- p = int64_vector_search (&v, &tmp, (void*) compare);
+ p = int64_vector_search (&v, &tmp, (void *)compare);
assert (p == &v.ptr[7]);
free (v.ptr);
diff --git a/python/handle.c b/python/handle.c
index 2b04cdcd..8ff6ba81 100644
--- a/python/handle.c
+++ b/python/handle.c
@@ -46,7 +46,7 @@ static inline PyObject *
put_handle (struct nbd_handle *h)
{
assert (h);
- return PyCapsule_New ((void *) h, "nbd_handle", NULL);
+ return PyCapsule_New ((void *)h, "nbd_handle", NULL);
}
PyObject *
@@ -188,7 +188,7 @@ nbd_internal_py_aio_buffer_is_zero (PyObject *self, PyObject *args)
"except -1 to mean to the end of the buffer");
goto out;
}
- else if ((size_t) offset + size > buf.len) {
+ else if ((size_t)offset + size > buf.len) {
PyErr_SetString (PyExc_IndexError, "size out of range");
goto out;
}
diff --git a/python/utils.c b/python/utils.c
index 27242f25..bf62f411 100644
--- a/python/utils.c
+++ b/python/utils.c
@@ -53,7 +53,7 @@ nbd_internal_py_get_string_list (PyObject *obj)
"get_string_list: PyList_Size failure");
return NULL;
}
- len = (size_t) slen;
+ len = (size_t)slen;
r = malloc (sizeof (char *) * (len+1));
if (r == NULL) {
PyErr_NoMemory ();
diff --git a/ocaml/nbd-c.h b/ocaml/nbd-c.h
index f853c84a..0cbe36d1 100644
--- a/ocaml/nbd-c.h
+++ b/ocaml/nbd-c.h
@@ -49,7 +49,7 @@ static inline value
caml_alloc_initialized_string (mlsize_t len, const char *p)
{
value sv = caml_alloc_string (len);
- memcpy ((char *) String_val (sv), p, len);
+ memcpy ((char *)String_val (sv), p, len);
return sv;
}
#endif
@@ -70,7 +70,7 @@ extern void nbd_internal_ocaml_exception_in_wrapper (const char *, value);
#define NBD_val(v) (*((struct nbd_handle **)Data_custom_val (v)))
static struct custom_operations libnbd_custom_operations = {
- (char *) "libnbd_custom_operations",
+ (char *)"libnbd_custom_operations",
nbd_internal_ocaml_handle_finalize,
custom_compare_default,
custom_hash_default,
@@ -110,7 +110,7 @@ struct nbd_buffer {
#define NBD_buffer_val(v) ((struct nbd_buffer *)Data_custom_val (v))
static struct custom_operations nbd_buffer_custom_operations = {
- (char *) "nbd_buffer_custom_operations",
+ (char *)"nbd_buffer_custom_operations",
nbd_internal_ocaml_buffer_finalize,
custom_compare_default,
custom_hash_default,
diff --git a/tests/aio-connect-port.c b/tests/aio-connect-port.c
index 05d33191..70138a80 100644
--- a/tests/aio-connect-port.c
+++ b/tests/aio-connect-port.c
@@ -87,7 +87,7 @@ main (int argc, char *argv[])
addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
addr.sin_port = htons (port);
- if (nbd_aio_connect (nbd, (struct sockaddr *) &addr, sizeof addr) == -1) {
+ if (nbd_aio_connect (nbd, (struct sockaddr *)&addr, sizeof addr) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/aio-connect.c b/tests/aio-connect.c
index 1601ed0b..aac82179 100644
--- a/tests/aio-connect.c
+++ b/tests/aio-connect.c
@@ -85,7 +85,7 @@ main (int argc, char *argv[])
addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
addr.sin_port = htons (port);
- if (nbd_aio_connect (nbd, (struct sockaddr *) &addr, sizeof addr) == -1) {
+ if (nbd_aio_connect (nbd, (struct sockaddr *)&addr, sizeof addr) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-bad-cookie.c b/tests/errors-bad-cookie.c
index c3de8c15..44479bdb 100644
--- a/tests/errors-bad-cookie.c
+++ b/tests/errors-bad-cookie.c
@@ -69,7 +69,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-client-oversize.c b/tests/errors-client-oversize.c
index 8f0c039c..db701687 100644
--- a/tests/errors-client-oversize.c
+++ b/tests/errors-client-oversize.c
@@ -80,7 +80,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-client-unadvertised-cmd.c b/tests/errors-client-unadvertised-cmd.c
index cd5a3e15..9dcd5766 100644
--- a/tests/errors-client-unadvertised-cmd.c
+++ b/tests/errors-client-unadvertised-cmd.c
@@ -80,7 +80,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-client-unaligned.c b/tests/errors-client-unaligned.c
index ec996b71..e7c62fe8 100644
--- a/tests/errors-client-unaligned.c
+++ b/tests/errors-client-unaligned.c
@@ -80,7 +80,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-client-unknown-flags.c b/tests/errors-client-unknown-flags.c
index 9d41de26..3399bbfd 100644
--- a/tests/errors-client-unknown-flags.c
+++ b/tests/errors-client-unknown-flags.c
@@ -73,7 +73,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-client-zerosize.c b/tests/errors-client-zerosize.c
index 3ed170a7..69026324 100644
--- a/tests/errors-client-zerosize.c
+++ b/tests/errors-client-zerosize.c
@@ -73,7 +73,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-connect-null.c b/tests/errors-connect-null.c
index e2542ff3..46114d0b 100644
--- a/tests/errors-connect-null.c
+++ b/tests/errors-connect-null.c
@@ -79,7 +79,7 @@ main (int argc, char *argv[])
}
check (EFAULT, "nbd_connect_command: ");
- if (nbd_connect_command (nbd, (char **) cmd) != -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) != -1) {
fprintf (stderr, "%s: test failed: "
"nbd_connect_command did not reject empty argv\n",
argv[0]);
diff --git a/tests/errors-connect-twice.c b/tests/errors-connect-twice.c
index 496fb521..f8053fc9 100644
--- a/tests/errors-connect-twice.c
+++ b/tests/errors-connect-twice.c
@@ -69,11 +69,11 @@ main (int argc, char *argv[])
}
/* Connect to a working server, then try to connect again. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
- if (nbd_connect_command (nbd, (char **) cmd) != -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) != -1) {
fprintf (stderr, "%s: test failed: "
"nbd_connect_command did not reject repeat attempt\n",
argv[0]);
diff --git a/tests/errors-multiple-disconnects.c b/tests/errors-multiple-disconnects.c
index 13f30139..25309867 100644
--- a/tests/errors-multiple-disconnects.c
+++ b/tests/errors-multiple-disconnects.c
@@ -133,7 +133,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-not-negotiating.c b/tests/errors-not-negotiating.c
index 2eed4181..7609de56 100644
--- a/tests/errors-not-negotiating.c
+++ b/tests/errors-not-negotiating.c
@@ -69,7 +69,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-notify-not-blocked.c b/tests/errors-notify-not-blocked.c
index 93903946..306540b5 100644
--- a/tests/errors-notify-not-blocked.c
+++ b/tests/errors-notify-not-blocked.c
@@ -69,7 +69,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-pread-structured.c b/tests/errors-pread-structured.c
index 946b14be..654d7b6d 100644
--- a/tests/errors-pread-structured.c
+++ b/tests/errors-pread-structured.c
@@ -95,7 +95,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-server-invalid-offset.c b/tests/errors-server-invalid-offset.c
index 8ce7c814..dba1a7ff 100644
--- a/tests/errors-server-invalid-offset.c
+++ b/tests/errors-server-invalid-offset.c
@@ -101,7 +101,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-server-oversize.c b/tests/errors-server-oversize.c
index 627d824b..c773ce29 100644
--- a/tests/errors-server-oversize.c
+++ b/tests/errors-server-oversize.c
@@ -117,7 +117,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-server-unadvertised-cmd.c b/tests/errors-server-unadvertised-cmd.c
index d63043a1..44c266ac 100644
--- a/tests/errors-server-unadvertised-cmd.c
+++ b/tests/errors-server-unadvertised-cmd.c
@@ -108,7 +108,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-server-unaligned.c b/tests/errors-server-unaligned.c
index a488570d..74cffaea 100644
--- a/tests/errors-server-unaligned.c
+++ b/tests/errors-server-unaligned.c
@@ -109,7 +109,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-server-unknown-flags.c b/tests/errors-server-unknown-flags.c
index 38e1c080..d4946822 100644
--- a/tests/errors-server-unknown-flags.c
+++ b/tests/errors-server-unknown-flags.c
@@ -101,7 +101,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/errors-server-zerosize.c b/tests/errors-server-zerosize.c
index 295e0b58..6011bbef 100644
--- a/tests/errors-server-zerosize.c
+++ b/tests/errors-server-zerosize.c
@@ -101,7 +101,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/opt-set-meta.c b/tests/opt-set-meta.c
index 7f4656b9..1bd60a9c 100644
--- a/tests/opt-set-meta.c
+++ b/tests/opt-set-meta.c
@@ -219,7 +219,7 @@ main (int argc, char *argv[])
* or newer with its --no-sr kill switch.
*/
requires ("nbdkit --no-sr --help");
- args[ARRAY_SIZE (args) - 2] = (char *) "--no-sr";
+ args[ARRAY_SIZE (args) - 2] = (char *)"--no-sr";
nbd = nbd_create ();
if (nbd == NULL ||
nbd_set_opt_mode (nbd, true) == -1 ||
diff --git a/tests/opt-starttls.c b/tests/opt-starttls.c
index 35668f17..ce966d81 100644
--- a/tests/opt-starttls.c
+++ b/tests/opt-starttls.c
@@ -97,7 +97,7 @@ do_test (const char *server_tls, struct expected exp)
"--filter=tls-fallback", "pattern",
"size=1M", "tlsreadme=fallback", NULL };
- if (nbd_connect_command (nbd, (char **) args) == -1) {
+ if (nbd_connect_command (nbd, (char **)args) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
@@ -163,7 +163,7 @@ main (int argc, char *argv[])
exit (77);
}
if (nbd_set_opt_mode (nbd, true) == -1 ||
- nbd_connect_command (nbd, (char **) args) == -1 ||
+ nbd_connect_command (nbd, (char **)args) == -1 ||
nbd_opt_info (nbd) != -1 ||
nbd_opt_info (nbd) != -1 ||
nbd_aio_is_dead (nbd) == 1) {
diff --git a/tests/opt-structured-twice.c b/tests/opt-structured-twice.c
index 17fab1f2..3892436a 100644
--- a/tests/opt-structured-twice.c
+++ b/tests/opt-structured-twice.c
@@ -60,7 +60,7 @@ main (int argc, char *argv[])
/* Connect to the server in opt mode, without structured replies. */
if (nbd_set_opt_mode (nbd, true) == -1 ||
nbd_set_request_structured_replies (nbd, false) == -1 ||
- nbd_connect_command (nbd, (char **) cmd) == -1) {
+ nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/pread-initialize.c b/tests/pread-initialize.c
index 585bf608..36d1aae2 100644
--- a/tests/pread-initialize.c
+++ b/tests/pread-initialize.c
@@ -71,7 +71,7 @@ main (int argc, char *argv[])
}
/* Connect to the server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/private-data.c b/tests/private-data.c
index 734698c9..25d4cc5c 100644
--- a/tests/private-data.c
+++ b/tests/private-data.c
@@ -62,8 +62,8 @@ main (int argc, char *argv[])
assert (nbd_get_private_data (nbd1) == 43);
/* Check that (in C) we can store and retrieve a pointer. */
- nbd_set_private_data (nbd1, (uintptr_t) &nbd_close);
- assert (nbd_get_private_data (nbd1) == (uintptr_t) &nbd_close);
+ nbd_set_private_data (nbd1, (uintptr_t)&nbd_close);
+ assert (nbd_get_private_data (nbd1) == (uintptr_t)&nbd_close);
nbd_close (nbd2);
nbd_close (nbd1);
diff --git a/tests/server-death.c b/tests/server-death.c
index e65737a7..caf95572 100644
--- a/tests/server-death.c
+++ b/tests/server-death.c
@@ -66,7 +66,7 @@ main (int argc, char *argv[])
}
/* Connect to a slow server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/tests/shutdown-flags.c b/tests/shutdown-flags.c
index bad638e9..4260425b 100644
--- a/tests/shutdown-flags.c
+++ b/tests/shutdown-flags.c
@@ -65,7 +65,7 @@ main (int argc, char *argv[])
}
/* Connect to a server. */
- if (nbd_connect_command (nbd, (char **) cmd) == -1) {
+ if (nbd_connect_command (nbd, (char **)cmd) == -1) {
fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ());
exit (EXIT_FAILURE);
}
diff --git a/examples/glib-main-loop.c b/examples/glib-main-loop.c
index 8403a970..38352683 100644
--- a/examples/glib-main-loop.c
+++ b/examples/glib-main-loop.c
@@ -79,7 +79,7 @@ events_from_nbd (struct nbd_handle *nbd)
static gboolean
prepare (GSource *sp, gint *timeout_)
{
- struct NBDSource *source = (struct NBDSource *) sp;
+ struct NBDSource *source = (struct NBDSource *)sp;
int new_fd;
int events;
@@ -89,13 +89,13 @@ prepare (GSource *sp, gint *timeout_)
new_fd = nbd_aio_get_fd (source->nbd);
if (source->fd != new_fd) {
if (source->tag != NULL) {
- g_source_remove_unix_fd ((GSource *) source, source->tag);
+ g_source_remove_unix_fd ((GSource *)source, source->tag);
source->fd = -1;
source->tag = NULL;
}
if (new_fd >= 0) {
source->fd = new_fd;
- source->tag = g_source_add_unix_fd ((GSource *) source, new_fd, 0);
+ source->tag = g_source_add_unix_fd ((GSource *)source, new_fd, 0);
}
}
@@ -103,7 +103,7 @@ prepare (GSource *sp, gint *timeout_)
return FALSE;
events = events_from_nbd (source->nbd);
- g_source_modify_unix_fd ((GSource *) source, source->tag, events);
+ g_source_modify_unix_fd ((GSource *)source, source->tag, events);
*timeout_ = -1;
DEBUG (source, "prepare: events = 0x%x%s%s",
@@ -125,14 +125,14 @@ prepare (GSource *sp, gint *timeout_)
static gboolean
check (GSource *sp)
{
- struct NBDSource *source = (struct NBDSource *) sp;
+ struct NBDSource *source = (struct NBDSource *)sp;
unsigned dir;
int revents;
if (!source->tag)
return FALSE;
- revents = g_source_query_unix_fd ((GSource *) source, source->tag);
+ revents = g_source_query_unix_fd ((GSource *)source, source->tag);
dir = nbd_aio_get_direction (source->nbd);
DEBUG (source, "check: direction = 0x%x%s%s, revents = 0x%x%s%s",
@@ -156,11 +156,11 @@ dispatch (GSource *sp,
GSourceFunc callback,
gpointer user_data)
{
- struct NBDSource *source = (struct NBDSource *) sp;
+ struct NBDSource *source = (struct NBDSource *)sp;
int revents;
int r;
- revents = g_source_query_unix_fd ((GSource *) source, source->tag);
+ revents = g_source_query_unix_fd ((GSource *)source, source->tag);
DEBUG (source, "dispatch: revents = 0x%x%s%s",
revents,
@@ -184,7 +184,7 @@ dispatch (GSource *sp,
static void
finalize (GSource *sp)
{
- struct NBDSource *source = (struct NBDSource *) sp;
+ struct NBDSource *source = (struct NBDSource *)sp;
DEBUG (source, "finalize");
@@ -211,7 +211,7 @@ create_libnbd_gsource (struct nbd_handle *nbd)
struct NBDSource *source;
source =
- (struct NBDSource *) g_source_new (&nbd_source_funcs, sizeof *source);
+ (struct NBDSource *)g_source_new (&nbd_source_funcs, sizeof *source);
source->nbd = nbd;
source->debug = nbd_get_debug (nbd);
source->fd = -1;
@@ -297,19 +297,19 @@ main (int argc, char *argv[])
gssrc = create_libnbd_gsource (src);
gsdest = create_libnbd_gsource (dest);
loopctx = g_main_loop_get_context (loop);
- g_source_attach ((GSource *) gssrc, loopctx);
- g_source_attach ((GSource *) gsdest, loopctx);
+ g_source_attach ((GSource *)gssrc, loopctx);
+ g_source_attach ((GSource *)gsdest, loopctx);
/* Make sure we get called back when each handle connects. */
gssrc->connected_callback = connected;
gsdest->connected_callback = connected;
/* Asynchronously start each handle connecting. */
- if (nbd_aio_connect_command (src, (char **) src_args) == -1) {
+ if (nbd_aio_connect_command (src, (char **)src_args) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
- if (nbd_aio_connect_command (dest, (char **) dest_args) == -1) {
+ if (nbd_aio_connect_command (dest, (char **)dest_args) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
@@ -482,11 +482,11 @@ finished_write (void *vp, int *error)
*/
if (finished && nr_buffers == 0) {
DEBUG (gsdest, "finished_write: all finished");
- g_source_remove (g_source_get_id ((GSource *) gssrc));
- g_source_unref ((GSource *) gssrc);
+ g_source_remove (g_source_get_id ((GSource *)gssrc));
+ g_source_unref ((GSource *)gssrc);
gssrc = NULL;
- g_source_remove (g_source_get_id ((GSource *) gsdest));
- g_source_unref ((GSource *) gsdest);
+ g_source_remove (g_source_get_id ((GSource *)gsdest));
+ g_source_unref ((GSource *)gsdest);
gsdest = NULL;
g_main_loop_quit (loop);
}
diff --git a/examples/open-qcow2.c b/examples/open-qcow2.c
index 70ea9b37..dd5b7c74 100644
--- a/examples/open-qcow2.c
+++ b/examples/open-qcow2.c
@@ -34,7 +34,7 @@ main (int argc, const char *argv[])
*/
char *args[] = {
"qemu-nbd", "-f", "qcow2",
- (char *) filename,
+ (char *)filename,
NULL
};
if (nbd_connect_systemd_socket_activation (nbd,
diff --git a/interop/list-exports.c b/interop/list-exports.c
index 8b15c815..26436cd6 100644
--- a/interop/list-exports.c
+++ b/interop/list-exports.c
@@ -75,7 +75,7 @@ append (void *opaque, const char *name, const char *description)
static int
compare_actuals (const void *vp1, const void *vp2)
{
- return strcmp (* (char * const *) vp1, * (char * const *) vp2);
+ return strcmp (*(char * const *)vp1, *(char * const *)vp2);
}
static void
diff --git a/copy/file-ops.c b/copy/file-ops.c
index 710fc68a..4f2ce738 100644
--- a/copy/file-ops.c
+++ b/copy/file-ops.c
@@ -334,7 +334,7 @@ file_close (struct rw *rw)
static void
file_truncate (struct rw *rw, int64_t size)
{
- struct rw_file *rwf = (struct rw_file *) rw;
+ struct rw_file *rwf = (struct rw_file *)rw;
/* If the destination is an ordinary file then the original file
* size doesn't matter. Truncate it to the source size. But
@@ -420,7 +420,7 @@ file_synch_read (struct rw *rw,
if (r == 0)
return n;
- data = (char *) data + r;
+ data = (char *)data + r;
offset += r;
len -= r;
n += r;
@@ -450,7 +450,7 @@ file_synch_write (struct rw *rw,
perror (rw->name);
exit (EXIT_FAILURE);
}
- data = (char *) data + r;
+ data = (char *)data + r;
offset += r;
len -= r;
}
diff --git a/copy/main.c b/copy/main.c
index 9c53842f..391c0c4f 100644
--- a/copy/main.c
+++ b/copy/main.c
@@ -290,7 +290,7 @@ main (int argc, char *argv[])
found1:
connections = 1; /* multi-conn not supported */
src =
- nbd_rw_create_subprocess ((const char **) &argv[optind+1], i-optind-1,
+ nbd_rw_create_subprocess ((const char **)&argv[optind+1], i-optind-1,
false);
optind = i+1;
}
@@ -315,7 +315,7 @@ main (int argc, char *argv[])
found2:
connections = 1; /* multi-conn not supported */
dst =
- nbd_rw_create_subprocess ((const char **) &argv[optind+1], i-optind-1,
+ nbd_rw_create_subprocess ((const char **)&argv[optind+1], i-optind-1,
true);
optind = i+1;
}
@@ -371,7 +371,7 @@ main (int argc, char *argv[])
#else
t = 1;
#endif
- threads = (unsigned) t;
+ threads = (unsigned)t;
}
if (synchronous)
@@ -534,7 +534,7 @@ open_local (const char *filename, direction d)
}
if (S_ISREG (stat.st_mode)) /* Regular file. */
return file_create (filename, fd,
- stat.st_size, (uint64_t) stat.st_blksize, false, d);
+ stat.st_size, (uint64_t)stat.st_blksize, false, d);
else if (S_ISBLK (stat.st_mode)) { /* Block device. */
unsigned int blkioopt;
@@ -549,7 +549,7 @@ open_local (const char *filename, direction d)
#endif
return file_create (filename, fd,
- stat.st_size, (uint64_t) blkioopt, true, d);
+ stat.st_size, (uint64_t)blkioopt, true, d);
}
else { /* Probably stdin/stdout, a pipe or a socket. */
synchronous = true; /* Force synchronous mode for pipes. */
diff --git a/copy/nbd-ops.c b/copy/nbd-ops.c
index 843b7c17..f3b3bed3 100644
--- a/copy/nbd-ops.c
+++ b/copy/nbd-ops.c
@@ -101,7 +101,7 @@ open_one_nbd_handle (struct rw_nbd *rwn)
case CREATE_SUBPROCESS:
if (nbd_connect_systemd_socket_activation (nbd,
- (char **) rwn->argv.ptr)
+ (char **)rwn->argv.ptr)
== -1) {
fprintf (stderr, "%s: %s: %s\n", prog, rwn->argv.ptr[0],
nbd_get_error ());
@@ -189,7 +189,7 @@ nbd_rw_create_subprocess (const char **argv, size_t argc, direction d)
static void
nbd_ops_close (struct rw *rw)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
size_t i;
for (i = 0; i < rwn->handles.len; ++i) {
@@ -208,7 +208,7 @@ nbd_ops_close (struct rw *rw)
static void
nbd_ops_flush (struct rw *rw)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
size_t i;
for (i = 0; i < rwn->handles.len; ++i) {
@@ -222,7 +222,7 @@ nbd_ops_flush (struct rw *rw)
static bool
nbd_ops_is_read_only (struct rw *rw)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (rwn->handles.len > 0)
return nbd_is_read_only (rwn->handles.ptr[0]);
@@ -233,7 +233,7 @@ nbd_ops_is_read_only (struct rw *rw)
static bool
nbd_ops_can_extents (struct rw *rw)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (rwn->handles.len > 0)
return nbd_can_meta_context (rwn->handles.ptr[0], "base:allocation");
@@ -244,7 +244,7 @@ nbd_ops_can_extents (struct rw *rw)
static bool
nbd_ops_can_multi_conn (struct rw *rw)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (rwn->handles.len > 0)
return nbd_can_multi_conn (rwn->handles.ptr[0]);
@@ -255,7 +255,7 @@ nbd_ops_can_multi_conn (struct rw *rw)
static void
nbd_ops_start_multi_conn (struct rw *rw)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
size_t i;
for (i = 1; i < connections; ++i)
@@ -268,7 +268,7 @@ static size_t
nbd_ops_synch_read (struct rw *rw,
void *data, size_t len, uint64_t offset)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (len > rw->size - offset)
len = rw->size - offset;
@@ -287,7 +287,7 @@ static void
nbd_ops_synch_write (struct rw *rw,
const void *data, size_t len, uint64_t offset)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (nbd_pwrite (rwn->handles.ptr[0], data, len, offset, 0) == -1) {
fprintf (stderr, "%s: %s\n", rw->name, nbd_get_error ());
@@ -299,7 +299,7 @@ static bool
nbd_ops_synch_zero (struct rw *rw, uint64_t offset, uint64_t count,
bool allocate)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (!rwn->can_zero)
return false;
@@ -317,7 +317,7 @@ nbd_ops_asynch_read (struct rw *rw,
struct command *command,
nbd_completion_callback cb)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (nbd_aio_pread (rwn->handles.ptr[command->worker->index],
slice_ptr (command->slice),
@@ -333,7 +333,7 @@ nbd_ops_asynch_write (struct rw *rw,
struct command *command,
nbd_completion_callback cb)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (nbd_aio_pwrite (rwn->handles.ptr[command->worker->index],
slice_ptr (command->slice),
@@ -348,7 +348,7 @@ static bool
nbd_ops_asynch_zero (struct rw *rw, struct command *command,
nbd_completion_callback cb, bool allocate)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (!rwn->can_zero)
return false;
@@ -367,7 +367,7 @@ nbd_ops_asynch_zero (struct rw *rw, struct command *command,
static unsigned
nbd_ops_in_flight (struct rw *rw, size_t index)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
/* Since the commands are auto-retired in the callbacks we don't
* need to count "done" commands.
@@ -379,7 +379,7 @@ static void
nbd_ops_get_polling_fd (struct rw *rw, size_t index,
int *fd, int *direction)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
struct nbd_handle *nbd;
nbd = rwn->handles.ptr[index];
@@ -402,7 +402,7 @@ nbd_ops_get_polling_fd (struct rw *rw, size_t index,
static void
nbd_ops_asynch_notify_read (struct rw *rw, size_t index)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (nbd_aio_notify_read (rwn->handles.ptr[index]) == -1) {
fprintf (stderr, "%s: %s\n", rw->name, nbd_get_error ());
exit (EXIT_FAILURE);
@@ -412,7 +412,7 @@ nbd_ops_asynch_notify_read (struct rw *rw, size_t index)
static void
nbd_ops_asynch_notify_write (struct rw *rw, size_t index)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
if (nbd_aio_notify_write (rwn->handles.ptr[index]) == -1) {
fprintf (stderr, "%s: %s\n", rw->name, nbd_get_error ());
exit (EXIT_FAILURE);
@@ -436,7 +436,7 @@ nbd_ops_get_extents (struct rw *rw, size_t index,
uint64_t offset, uint64_t count,
extent_list *ret)
{
- struct rw_nbd *rwn = (struct rw_nbd *) rw;
+ struct rw_nbd *rwn = (struct rw_nbd *)rw;
extent_list exts = empty_vector;
struct nbd_handle *nbd;
diff --git a/copy/pipe-ops.c b/copy/pipe-ops.c
index 596f3fed..bd8b7645 100644
--- a/copy/pipe-ops.c
+++ b/copy/pipe-ops.c
@@ -51,7 +51,7 @@ pipe_create (const char *name, int fd)
static void
pipe_close (struct rw *rw)
{
- struct rw_pipe *rwp = (struct rw_pipe *) rw;
+ struct rw_pipe *rwp = (struct rw_pipe *)rw;
if (close (rwp->fd) == -1) {
fprintf (stderr, "%s: close: %m\n", rw->name);
@@ -96,7 +96,7 @@ static size_t
pipe_synch_read (struct rw *rw,
void *data, size_t len, uint64_t offset)
{
- struct rw_pipe *rwp = (struct rw_pipe *) rw;
+ struct rw_pipe *rwp = (struct rw_pipe *)rw;
ssize_t r;
r = read (rwp->fd, data, len);
@@ -111,7 +111,7 @@ static void
pipe_synch_write (struct rw *rw,
const void *data, size_t len, uint64_t offset)
{
- struct rw_pipe *rwp = (struct rw_pipe *) rw;
+ struct rw_pipe *rwp = (struct rw_pipe *)rw;
while (len > 0) {
ssize_t r = write (rwp->fd, data, len);
@@ -119,7 +119,7 @@ pipe_synch_write (struct rw *rw,
perror (rw->name);
exit (EXIT_FAILURE);
}
- data = (char *) data + r;
+ data = (char *)data + r;
len -= r;
}
}
diff --git a/dump/dump.c b/dump/dump.c
index 3de24a12..b4aebe84 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -398,7 +398,7 @@ do_dump (void)
/* Print the ASCII codes. */
printf ("%s", pipe);
for (j = i; j < MIN (i+16, n); ++j) {
- char c = (char) buffer[j];
+ char c = (char)buffer[j];
if (isalnum (c)) {
ansi_colour (ANSI_FG_BRIGHT_RED, stdout);
printf ("%c", c);
diff --git a/fuse/nbdfuse.c b/fuse/nbdfuse.c
index d3eca256..491f6db8 100644
--- a/fuse/nbdfuse.c
+++ b/fuse/nbdfuse.c
@@ -109,7 +109,7 @@ fuse_help (const char *prog)
{
static struct fuse_operations null_operations;
const char *tmp_argv[] = { prog, "--help", NULL };
- fuse_main (2, (char **) tmp_argv, &null_operations, NULL);
+ fuse_main (2, (char **)tmp_argv, &null_operations, NULL);
exit (EXIT_SUCCESS);
}
@@ -415,7 +415,7 @@ main (int argc, char *argv[])
handles_append (&nbd, h); /* reserved above, so can't fail */
}
}
- connections = (unsigned) nbd.len;
+ connections = (unsigned)nbd.len;
if (verbose)
fprintf (stderr, "nbdfuse: connections=%u\n", connections);
@@ -424,7 +424,7 @@ main (int argc, char *argv[])
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
- size = (uint64_t) ssize;
+ size = (uint64_t)ssize;
/* If the remote NBD server is readonly, then act as if the '-r'
* flag was given on the nbdfuse command line.
@@ -481,7 +481,7 @@ main (int argc, char *argv[])
if (pidfile) {
fp = fopen (pidfile, "w");
if (fp) {
- fprintf (fp, "%ld", (long) getpid ());
+ fprintf (fp, "%ld", (long)getpid ());
fclose (fp);
}
}
diff --git a/fuse/operations.c b/fuse/operations.c
index 6f6bee3a..2d0634dc 100644
--- a/fuse/operations.c
+++ b/fuse/operations.c
@@ -380,7 +380,7 @@ nbdfuse_read (const char *path, char *buf,
struct fuse_file_info *fi)
{
DEBUG_OPERATION ("read", "path=%s, buf=%p, count=%zu, offset=%" PRIi64,
- path, buf, count, (int64_t) offset);
+ path, buf, count, (int64_t)offset);
if (!file_mode && (path[0] != '/' || strcmp (path+1, filename) != 0))
return -ENOENT;
@@ -396,7 +396,7 @@ nbdfuse_read (const char *path, char *buf,
CHECK_NBD_ASYNC_ERROR (nbd_aio_pread (h, buf, count, offset, cb, 0));
- return (int) count;
+ return (int)count;
}
static int
@@ -405,7 +405,7 @@ nbdfuse_write (const char *path, const char *buf,
struct fuse_file_info *fi)
{
DEBUG_OPERATION ("write", "path=%s, buf=%p, count=%zu, offset=%" PRIi64,
- path, buf, count, (int64_t) offset);
+ path, buf, count, (int64_t)offset);
/* Probably shouldn't happen because of nbdfuse_open check. */
if (readonly)
@@ -425,7 +425,7 @@ nbdfuse_write (const char *path, const char *buf,
CHECK_NBD_ASYNC_ERROR (nbd_aio_pwrite (h, buf, count, offset, cb, 0));
- return (int) count;
+ return (int)count;
}
static int
@@ -460,7 +460,7 @@ nbdfuse_fallocate (const char *path, int mode, off_t offset, off_t len,
{
DEBUG_OPERATION ("fallocate", "path=%s, mode=%d, "
"offset=%" PRIi64 ", len=%" PRIi64,
- path, mode, (int64_t) offset, (int64_t) len);
+ path, mode, (int64_t)offset, (int64_t)len);
if (readonly)
return -EACCES;
diff --git a/ublk/nbdublk.c b/ublk/nbdublk.c
index b079d577..b85ac609 100644
--- a/ublk/nbdublk.c
+++ b/ublk/nbdublk.c
@@ -347,7 +347,7 @@ main (int argc, char *argv[])
handles_append (&nbd, h); /* reserved above, so can't fail */
}
}
- connections = (unsigned) nbd.len;
+ connections = (unsigned)nbd.len;
/* Get the size and preferred block sizes. */
rs = nbd_get_size (nbd.ptr[0]);
@@ -355,7 +355,7 @@ main (int argc, char *argv[])
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
- size = (uint64_t) rs;
+ size = (uint64_t)rs;
rs = nbd_get_block_size (nbd.ptr[0], LIBNBD_SIZE_MAXIMUM);
if (rs <= 0 || rs > 64 * 1024 * 1024)
diff --git a/ublk/tgt.c b/ublk/tgt.c
index 77d39661..20971bdb 100644
--- a/ublk/tgt.c
+++ b/ublk/tgt.c
@@ -120,7 +120,7 @@ aio_submitter (struct ublksrv_aio_ctx *ctx, struct ublksrv_aio *req)
switch (op) {
case UBLK_IO_OP_READ:
- r = nbd_aio_pread (h, (void *) iod->addr, iod->nr_sectors << 9,
+ r = nbd_aio_pread (h, (void *)iod->addr, iod->nr_sectors << 9,
iod->start_sector << 9, cb, 0);
if (r == -1) {
fprintf (stderr, "%s: %s\n", "nbdublk", nbd_get_error ());
@@ -132,7 +132,7 @@ aio_submitter (struct ublksrv_aio_ctx *ctx, struct ublksrv_aio *req)
if (fua && can_fua)
nbd_flags |= LIBNBD_CMD_FLAG_FUA;
- r = nbd_aio_pwrite (h, (const void *) iod->addr, iod->nr_sectors << 9,
+ r = nbd_aio_pwrite (h, (const void *)iod->addr, iod->nr_sectors << 9,
iod->start_sector << 9, cb, nbd_flags);
if (r == -1) {
fprintf (stderr, "%s: %s\n", "nbdublk", nbd_get_error ());
--
2.40.1
1 year, 6 months