Factor out the " ||\n " separator string from the
"String.concat"
call, and reuse it within the Connected state mapping.
An example of the effect [lib/api.c]:
@@ -625,7 +625,8 @@ get_canonical_export_name_in_permitted_s
const enum state state = get_public_state (h);
if (!(nbd_internal_is_state_negotiating (state) ||
- nbd_internal_is_state_ready (state) || nbd_internal_is_state_processing (state)
||
+ nbd_internal_is_state_ready (state) ||
+ nbd_internal_is_state_processing (state) ||
nbd_internal_is_state_closed (state))) {
set_error (nbd_internal_is_state_created (state) ? ENOTCONN : EINVAL,
"invalid state: %s: the handle must be %s",
Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=2172516
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
generator/C.ml | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/generator/C.ml b/generator/C.ml
index ce6ff69419a5..f7a306de39d8 100644
--- a/generator/C.ml
+++ b/generator/C.ml
@@ -533,17 +533,21 @@ let
pr "{\n";
pr " const enum state state = get_public_state (h);\n";
pr "\n";
+ let or_nl_indent = " ||\n " in
let tests =
List.map (
function
| Created -> "nbd_internal_is_state_created (state)"
| Connecting -> "nbd_internal_is_state_connecting (state)"
| Negotiating -> "nbd_internal_is_state_negotiating (state)"
- | Connected -> "nbd_internal_is_state_ready (state) ||
nbd_internal_is_state_processing (state)"
+ | Connected ->
+ "nbd_internal_is_state_ready (state)" ^
+ or_nl_indent ^
+ "nbd_internal_is_state_processing (state)"
| Closed -> "nbd_internal_is_state_closed (state)"
| Dead -> "nbd_internal_is_state_dead (state)"
) permitted_states in
- pr " if (!(%s)) {\n" (String.concat " ||\n " tests);
+ pr " if (!(%s)) {\n" (String.concat or_nl_indent tests);
pr " set_error (nbd_internal_is_state_created (state) ? ENOTCONN :
EINVAL,\n";
pr " \"invalid state: %%s: the handle must be
%%s\",\n";
pr " nbd_internal_state_short_string (state),\n";