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]
Date:	Mon, 9 Mar 2015 14:51:17 +0100
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Adrian Remonda <adrianremonda@...il.com>
Cc:	Mark Brown <broonie@...nel.org>, Jonathan Corbet <corbet@....net>,
	linux-spi <linux-spi@...r.kernel.org>,
	"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/4] Cleaned hexadecimal dump

On Sat, Mar 7, 2015 at 6:56 PM, Adrian Remonda <adrianremonda@...il.com> wrote:
> diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c
> index 3a2f9d59edab..533050ced9f1 100644
> --- a/Documentation/spi/spidev_test.c
> +++ b/Documentation/spi/spidev_test.c
> @@ -15,6 +15,7 @@
>  #include <unistd.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> +#include <string.h>
>  #include <getopt.h>
>  #include <fcntl.h>
>  #include <sys/ioctl.h>
> @@ -35,6 +36,33 @@ static uint8_t bits = 8;
>  static uint32_t speed = 500000;
>  static uint16_t delay;
>
> +static void hexDump(const void *src, size_t length, size_t bLine, char *prefix)
> +{
> +       int i = 0;
> +       char *address = (char *)src;

If you use "const char *address", you don't need the cast.
If you use "const unsigned char *address", one more cast below can be dropped.

> +       char *line = (char *)address;

"const unsigned char *line", and drop the cast.

> +       unsigned char c;
> +
> +       printf("%s | ", prefix);
> +       while (length-- > 0) {
> +               printf("%02X ", (unsigned char)*address++);

> @@ -76,12 +104,7 @@ static void transfer(int fd)
>         if (ret < 1)
>                 pabort("can't send spi message");
>
> -       for (ret = 0; ret < ARRAY_SIZE(tx); ret++) {
> -               if (!(ret % 6))
> -                       puts("");
> -               printf("%.2X ", rx[ret]);
> -       }
> -       puts("");
> +       hexDump(rx, ARRAY_SIZE(tx), 32, "RX");

I know rx and tx have the same size, but please switch to "ARRAY_SIZE(RX)"
while at it.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ