[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities
From: |
Bruno Haible |
Subject: |
Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities |
Date: |
Sat, 05 May 2018 18:14:05 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-119-generic; KDE/5.18.0; x86_64; ; ) |
While writing the documentation, I noticed that the function has an
argument list that is hard to remember:
- an input argument (stream),
- an output buffer (resblock),
- an input argument (alg),
- the size of the output buffer.
It is better to reorder the arguments so as to:
1. group the input arguments together,
2. group the output buffer and its size together.
2018-05-05 Bruno Haible <address@hidden>
af_alg: Improve function signature.
* lib/af_alg.h (afalg_stream): Swap second and third argument.
* lib/af_alg.c (afalg_stream): Likewise.
* lib/md5.c, lib/sha1.c, lib/sha256.c, lib/sha512.c: Callers changed.
diff --git a/lib/af_alg.c b/lib/af_alg.c
index 3af099e..91f565d 100644
--- a/lib/af_alg.c
+++ b/lib/af_alg.c
@@ -35,7 +35,7 @@
#define BLOCKSIZE 32768
int
-afalg_stream (FILE * stream, void *resblock, const char *alg, ssize_t hashlen)
+afalg_stream (FILE * stream, const char *alg, void *resblock, ssize_t hashlen)
{
struct sockaddr_alg salg = {
.salg_family = AF_ALG,
diff --git a/lib/af_alg.h b/lib/af_alg.h
index e9580d4..aacb8f6 100644
--- a/lib/af_alg.h
+++ b/lib/af_alg.h
@@ -58,12 +58,12 @@ extern "C" {
If successful, this function fills RESBLOCK and returns 0.
Upon failure, it returns a negated error code. */
int
-afalg_stream (FILE *stream, void *resblock, const char *alg, ssize_t hashlen);
+afalg_stream (FILE *stream, const char *alg, void *resblock, ssize_t hashlen);
# else
static int
-afalg_stream (FILE *stream, void *resblock, const char *alg, ssize_t hashlen)
+afalg_stream (FILE *stream, const char *alg, void *resblock, ssize_t hashlen)
{
return -EAFNOSUPPORT;
}
diff --git a/lib/md5.c b/lib/md5.c
index 307abbb..e6bd209 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -151,7 +151,7 @@ md5_stream (FILE *stream, void *resblock)
#ifdef HAVE_LINUX_IF_ALG_H
int ret;
- ret = afalg_stream(stream, resblock, "md5", MD5_DIGEST_SIZE);
+ ret = afalg_stream (stream, "md5", resblock, MD5_DIGEST_SIZE);
if (!ret)
return 0;
diff --git a/lib/sha1.c b/lib/sha1.c
index a84bf21..b670267 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -138,7 +138,7 @@ sha1_stream (FILE *stream, void *resblock)
#ifdef HAVE_LINUX_IF_ALG_H
int ret;
- ret = afalg_stream(stream, resblock, "sha1", SHA1_DIGEST_SIZE);
+ ret = afalg_stream (stream, "sha1", resblock, SHA1_DIGEST_SIZE);
if (!ret)
return 0;
diff --git a/lib/sha256.c b/lib/sha256.c
index 578f43e..fab119a 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -186,7 +186,7 @@ sha256_stream (FILE *stream, void *resblock)
#ifdef HAVE_LINUX_IF_ALG_H
int ret;
- ret = afalg_stream(stream, resblock, "sha256", SHA256_DIGEST_SIZE);
+ ret = afalg_stream(stream, "sha256", resblock, SHA256_DIGEST_SIZE);
if (!ret)
return 0;
@@ -269,7 +269,7 @@ sha224_stream (FILE *stream, void *resblock)
#ifdef HAVE_LINUX_IF_ALG_H
int ret;
- ret = afalg_stream(stream, resblock, "sha224", SHA224_DIGEST_SIZE);
+ ret = afalg_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE);
if (!ret)
return 0;
diff --git a/lib/sha512.c b/lib/sha512.c
index 72e5fdd..ff7c0cb 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -194,7 +194,7 @@ sha512_stream (FILE *stream, void *resblock)
#ifdef HAVE_LINUX_IF_ALG_H
int ret;
- ret = afalg_stream(stream, resblock, "sha512", SHA512_DIGEST_SIZE);
+ ret = afalg_stream (stream, "sha512", resblock, SHA512_DIGEST_SIZE);
if (!ret)
return 0;
@@ -277,7 +277,7 @@ sha384_stream (FILE *stream, void *resblock)
#ifdef HAVE_LINUX_IF_ALG_H
int ret;
- ret = afalg_stream(stream, resblock, "sha384", SHA384_DIGEST_SIZE);
+ ret = afalg_stream (stream, "sha384", resblock, SHA384_DIGEST_SIZE);
if (!ret)
return 0;
- Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities, Bruno Haible, 2018/05/05
- Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities, Bruno Haible, 2018/05/05
- Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities, Bruno Haible, 2018/05/05
- Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities,
Bruno Haible <=
- Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities, Bruno Haible, 2018/05/05
- Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities, Bruno Haible, 2018/05/05
- Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities, Bruno Haible, 2018/05/05
- Re: [PATCH v3 0/4] Use AF_ALG in checksum utilities, Bruno Haible, 2018/05/06