Laszlo Ersek
2023-Feb-15 14:11 UTC
[Libguestfs] [libnbd PATCH v3 02/29] generator/C.ml: use space consistently in func. and func.-like macro calls
Apply the ideas in the previous patch to the C-language bindings generator. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- generator/C.ml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/generator/C.ml b/generator/C.ml index f9171996dde0..07c924c48ccf 100644 --- a/generator/C.ml +++ b/generator/C.ml @@ -250,15 +250,15 @@ let *) (match ret with | RString -> - pr "\n LIBNBD_ATTRIBUTE_ALLOC_DEALLOC(__builtin_free)"; + pr "\n LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)"; | _ -> () ); (* Output __attribute__((nonnull)) for the function parameters: * eg. struct nbd_handle *, int, char * * => [ true, false, true ] - * => LIBNBD_ATTRIBUTE_NONNULL(1,3) - * => __attribute__((nonnull(1,3))) + * => LIBNBD_ATTRIBUTE_NONNULL (1, 3) + * => __attribute__ ((nonnull (1, 3))) *) let nns : bool list [ true ] (* struct nbd_handle * *) @@ -267,7 +267,7 @@ let let nns = List.mapi (fun i b -> (i+1, b)) nns in let nns = filter_map (fun (i, b) -> if b then Some i else None) nns in let nns : string list = List.map string_of_int nns in - pr "\n LIBNBD_ATTRIBUTE_NONNULL(%s);\n" (String.concat "," nns) + pr "\n LIBNBD_ATTRIBUTE_NONNULL (%s);\n" (String.concat ", " nns) let rec print_cbarg_list ?(wrap = false) ?maxcol ?types ?(parens = true) cbargs @@ -400,22 +400,22 @@ let pr "extern \"C\" {\n"; pr "#endif\n"; pr "\n"; - pr "#if defined(__GNUC__)\n"; + pr "#if defined (__GNUC__)\n"; pr "#define LIBNBD_GCC_VERSION \\\n"; pr " (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)\n"; pr "#endif\n"; pr "\n"; pr "#ifndef LIBNBD_ATTRIBUTE_NONNULL\n"; - pr "#if defined(__GNUC__) && LIBNBD_GCC_VERSION >= 120000 /* gcc >= 12.0 */\n"; - pr "#define LIBNBD_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))\n"; + pr "#if defined (__GNUC__) && LIBNBD_GCC_VERSION >= 120000 /* gcc >= 12.0 */\n"; + pr "#define LIBNBD_ATTRIBUTE_NONNULL(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))\n"; pr "#else\n"; pr "#define LIBNBD_ATTRIBUTE_NONNULL(...)\n"; pr "#endif\n"; pr "#endif /* ! defined LIBNBD_ATTRIBUTE_NONNULL */\n"; pr "\n"; - pr "#if defined(__GNUC__) && LIBNBD_GCC_VERSION >= 120000 /* gcc >= 12.0 */\n"; + pr "#if defined (__GNUC__) && LIBNBD_GCC_VERSION >= 120000 /* gcc >= 12.0 */\n"; pr "#define LIBNBD_ATTRIBUTE_ALLOC_DEALLOC(fn) \\\n"; - pr " __attribute__((__malloc__, __malloc__(fn, 1)))\n"; + pr " __attribute__ ((__malloc__, __malloc__ (fn, 1)))\n"; pr "#else\n"; pr "#define LIBNBD_ATTRIBUTE_ALLOC_DEALLOC(fn)\n"; pr "#endif\n"; @@ -454,7 +454,7 @@ let pr "#define LIBNBD_HAVE_NBD_CLOSE 1\n"; pr "\n"; pr "extern struct nbd_handle *nbd_create (void)\n"; - pr " LIBNBD_ATTRIBUTE_ALLOC_DEALLOC(nbd_close);\n"; + pr " LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (nbd_close);\n"; pr "#define LIBNBD_HAVE_NBD_CREATE 1\n"; pr "\n"; pr "extern const char *nbd_get_error (void);\n";
Eric Blake
2023-Feb-15 19:54 UTC
[Libguestfs] [libnbd PATCH v3 02/29] generator/C.ml: use space consistently in func. and func.-like macro calls
On Wed, Feb 15, 2023 at 03:11:31PM +0100, Laszlo Ersek wrote:> Apply the ideas in the previous patch to the C-language bindings > generator. > > Signed-off-by: Laszlo Ersek <lersek at redhat.com> > --- > generator/C.ml | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) >> pr "#ifndef LIBNBD_ATTRIBUTE_NONNULL\n"; > - pr "#if defined(__GNUC__) && LIBNBD_GCC_VERSION >= 120000 /* gcc >= 12.0 */\n"; > - pr "#define LIBNBD_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))\n"; > + pr "#if defined (__GNUC__) && LIBNBD_GCC_VERSION >= 120000 /* gcc >= 12.0 */\n"; > + pr "#define LIBNBD_ATTRIBUTE_NONNULL(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))\n";Not only are these lines long in our source, they are long in the generated libnbd.h. I would not be opposed to a followup patch that tries harder at keeping the generated file under 80 columns (but there are already places where that is harder than this snippet - such as the generated declaration of nbd_aio_opt_list_meta_context), but it does not need to happen in this patch. And while I mentioned in 01/29 about the possibility of a C code formatter as a CI step for *.[ch], it would be even harder to insist that generated code matches a given style (it's always a nice goal for generated files to be human-readable where possible, but I'd much rather sacrifice that if it gets in the way of actually implementing the generator concisely). Reviewed-by: Eric Blake <eblake at redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Laszlo Ersek
2023-Feb-22 12:17 UTC
[Libguestfs] [libnbd PATCH v3 02/29] generator/C.ml: use space consistently in func. and func.-like macro calls
On 2/15/23 15:11, Laszlo Ersek wrote:> Apply the ideas in the previous patch to the C-language bindings > generator. > > Signed-off-by: Laszlo Ersek <lersek at redhat.com> > --- > generator/C.ml | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-)Merged this patch as commit b490830a9a78 ("generator/C.ml: use space consistently in func. and func.-like macro calls", 2023-02-22). Updated the "previous patch" term in the commit message to an actual commit reference. Picked up Eric's R-b from this thread, and Rich's from the patch#4 subthread. Recorded another task (recommended by Eric) at <https://bugzilla.redhat.com/show_bug.cgi?id=2172516#c1>. Laszlo
Seemingly Similar Threads
- [libnbd PATCH v3 02/29] generator/C.ml: use space consistently in func. and func.-like macro calls
- [libnbd PATCH v4 1/3] lib/utils: introduce xwritel() as a more robust and convenient write()
- [libnbd PATCH v4 0/3] lib/utils: add async-signal-safe assert()
- [libnbd PATCH v4 0/2] lib/utils: introduce async-signal-safe execvpe()
- [libnbd PATCH v3 07/29] lib/utils: add async-signal-safe assert()