On Wed, Sep 28, 2022 at 06:25:35PM +0100, Richard W.M. Jones wrote:
> For API parameters that are pointers and must not be NULL, add the
> appropriate GCC annotations.
> 
> Reviewed-by: Laszlo Ersek <ler...@redhat.com>
> ---
>  generator/C.ml              | 59 +++++++++++++++++++++++++++++++++++--
>  tests/errors-connect-null.c |  4 +++
>  2 files changed, 61 insertions(+), 2 deletions(-)

> @@ -216,7 +238,21 @@ let
>  let print_fndecl ?wrap ?closure_style name args optargs ret =
>    pr "extern ";
>    print_call ?wrap ?closure_style name args optargs ret;
> -  pr ";\n"
> +
> +  (* 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)))

Comment typo: No ',' before the innermost '('.

> +   *)
> +  let nns : bool list =
> +    [ true ] (* struct nbd_handle * *)
> +    @ List.flatten (List.map arg_attr_nonnull args)
> +    @ List.flatten (List.map optarg_attr_nonnull optargs) in
> +  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)
>  
>  let rec print_cbarg_list ?(wrap = false) ?maxcol ?types ?(parens = true)
>            cbargs =

The typo's easy to fix,
Reviewed-by: Eric Blake <ebl...@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to