lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221007074456.l2sh3s2siuv2a74m@pengutronix.de>
Date:   Fri, 7 Oct 2022 09:44:56 +0200
From:   Marc Kleine-Budde <mkl@...gutronix.de>
To:     Vincent Mailhol <mailhol.vincent@...adoo.fr>
Cc:     netdev@...r.kernel.org, linux-can@...r.kernel.org
Subject: Re: [PATCH iproute2-next 5.16 v6 3/5] iplink_can: use PRINT_ANY to
 factorize code and fix signedness

On 04.11.2021 01:44:26, Vincent Mailhol wrote:
> Current implementation heavily relies on some "if (is_json_context())"
> switches to decide the context and then does some print_*(PRINT_JSON,
> ...) when in json context and some fprintf(...) else.
> 
> Furthermore, current implementation uses either print_int() or the
> conversion specifier %d to print unsigned integers.
> 
> This patch factorizes each pairs of print_*(PRINT_JSON, ...) and
> fprintf() into a single print_*(PRINT_ANY, ...) call. While doing this
> replacement, it uses proper unsigned function print_uint() as well as
> the conversion specifier %u when the parameter is an unsigned integer.
> 
> Signed-off-by: Vincent Mailhol <mailhol.vincent@...adoo.fr>

[...]

>  	if (tb[IFLA_CAN_TERMINATION_CONST] && tb[IFLA_CAN_TERMINATION]) {
> @@ -538,29 +483,21 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>  			sizeof(*trm_const);
>  		int i;
>  
> -		if (is_json_context()) {
> -			print_hu(PRINT_JSON, "termination", NULL, *trm);
> -			open_json_array(PRINT_JSON, "termination_const");
> -			for (i = 0; i < trm_cnt; ++i)
> -				print_hu(PRINT_JSON, NULL, NULL, trm_const[i]);
> -			close_json_array(PRINT_JSON, NULL);
> -		} else {
> -			fprintf(f, "\n	  termination %hu [ ", *trm);
> -
> -			for (i = 0; i < trm_cnt - 1; ++i)
> -				fprintf(f, "%hu, ", trm_const[i]);
> -
> -			fprintf(f, "%hu ]", trm_const[i]);
                                        ^
> -		}
> +		can_print_nl_indent();
> +		print_hu(PRINT_ANY, "termination", " termination %hu [ ", *trm);

Always '['

> +		open_json_array(PRINT_JSON, "termination_const");
> +		for (i = 0; i < trm_cnt; ++i)
> +			print_hu(PRINT_ANY, NULL,
> +				 i < trm_cnt - 1 ? "%hu, " : "%hu",
> +				 trm_const[i]);
> +		close_json_array(PRINT_JSON, " ]");

']' only for JSON.

>  	}

I just noticed that the non JSON output for termination is missing the
closing ']'. See the output in the documentation update by Daniel:

| https://lore.kernel.org/all/4514353.LvFx2qVVIh@daniel6430

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ