[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 8/9] ccid-card-passthru: Use size_t to hold s
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH v2 8/9] ccid-card-passthru: Use size_t to hold size argument |
Date: |
Fri, 15 Feb 2019 12:51:23 +0100 |
Hi
On Thu, Feb 14, 2019 at 9:28 PM Philippe Mathieu-Daudé
<address@hidden> wrote:
>
> check_atr() is called once with a unsigned argument.
> Since there is no need to use a signed type, use a size_t.
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
and make data const?
Reviewed-by: Marc-André Lureau <address@hidden>
> ---
> hw/usb/ccid-card-passthru.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
> index d63aa28584..083eb5ca08 100644
> --- a/hw/usb/ccid-card-passthru.c
> +++ b/hw/usb/ccid-card-passthru.c
> @@ -149,9 +149,10 @@ static void ccid_card_vscard_handle_init(
> ccid_card_vscard_send_init(card);
> }
>
> -static int check_atr(PassthruState *card, uint8_t *data, int len)
> +static int check_atr(PassthruState *card, uint8_t *data, size_t len)
> {
> - int historical_length, opt_bytes;
> + size_t historical_length;
> + int opt_bytes;
> int td_count = 0;
> int td;
>
> @@ -185,18 +186,18 @@ static int check_atr(PassthruState *card, uint8_t
> *data, int len)
> }
> if (len < 2 + historical_length + opt_bytes) {
> DPRINTF(card, D_WARN,
> - "atr too short: len %d, but historical_len %d, T1 0x%X\n",
> + "atr too short: len %zu, but historical_len %zu, T1 0x%X\n",
> len, historical_length, data[1]);
> return 0;
> }
> if (len > 2 + historical_length + opt_bytes) {
> DPRINTF(card, D_WARN,
> - "atr too long: len %d, but hist/opt %d/%d, T1 0x%X\n",
> + "atr too long: len %zu, but hist/opt %zu/%d, T1 0x%X\n",
> len, historical_length, opt_bytes, data[1]);
> /* let it through */
> }
> DPRINTF(card, D_VERBOSE,
> - "atr passes check: %d total length, %d historical, %d
> optional\n",
> + "atr passes check: %zu total length, %zu historical, %d
> optional\n",
> len, historical_length, opt_bytes);
>
> return 1;
> --
> 2.20.1
>
>
--
Marc-André Lureau
- Re: [Qemu-devel] [PATCH v2 4/9] ccid-card-passthru: Let the chardev::read() be more generic, (continued)
- [Qemu-devel] [PATCH v2 5/9] ccid-card-passthru: Replace assert() by QEMU_BUILD_BUG_ON(), Philippe Mathieu-Daudé, 2019/02/14
- [Qemu-devel] [PATCH v2 7/9] ccid-card-passthru: Use QERR_MISSING_PARAMETER, Philippe Mathieu-Daudé, 2019/02/14
- [Qemu-devel] [PATCH v2 6/9] ccid-card-passthru: Simplify the if() condition, Philippe Mathieu-Daudé, 2019/02/14
- [Qemu-devel] [PATCH v2 9/9] ccid-card-passthru: Use size_t for index, Philippe Mathieu-Daudé, 2019/02/14
- [Qemu-devel] [PATCH v2 8/9] ccid-card-passthru: Use size_t to hold size argument, Philippe Mathieu-Daudé, 2019/02/14
- Re: [Qemu-devel] [PATCH v2 8/9] ccid-card-passthru: Use size_t to hold size argument,
Marc-André Lureau <=