mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto: digest: Make string arguments const
@ 2015-03-12  7:17 Sascha Hauer
  2015-03-12  7:17 ` [PATCH 2/2] crypto: digest: Fix coding style Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2015-03-12  7:17 UTC (permalink / raw)
  To: Barebox List

Most string arguments for keys and filenames can be const. Change
that.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 crypto/digest.c  | 18 +++++++++---------
 include/digest.h | 19 ++++++++++---------
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/crypto/digest.c b/crypto/digest.c
index 2f2039c..922d9d0 100644
--- a/crypto/digest.c
+++ b/crypto/digest.c
@@ -28,7 +28,7 @@
 
 static LIST_HEAD(digests);
 
-static struct digest_algo* digest_algo_get_by_name(char* name);
+static struct digest_algo* digest_algo_get_by_name(const char *name);
 
 static int dummy_init(struct digest *d)
 {
@@ -69,7 +69,7 @@ void digest_algo_unregister(struct digest_algo *d)
 }
 EXPORT_SYMBOL(digest_algo_unregister);
 
-static struct digest_algo *digest_algo_get_by_name(char* name)
+static struct digest_algo *digest_algo_get_by_name(const char *name)
 {
 	struct digest_algo* d;
 
@@ -84,7 +84,7 @@ static struct digest_algo *digest_algo_get_by_name(char* name)
 	return NULL;
 }
 
-struct digest *digest_alloc(char* name)
+struct digest *digest_alloc(const char *name)
 {
 	struct digest* d;
 	struct digest_algo* algo;
@@ -115,8 +115,8 @@ void digest_free(struct digest *d)
 }
 EXPORT_SYMBOL_GPL(digest_free);
 
-int digest_file_window(struct digest *d, char *filename,
-		       unsigned char *key, size_t keylen,
+int digest_file_window(struct digest *d, const char *filename,
+		       const unsigned char *key, size_t keylen,
 		       unsigned char *hash,
 		       ulong start, ulong size)
 {
@@ -189,8 +189,8 @@ out:
 }
 EXPORT_SYMBOL_GPL(digest_file_window);
 
-int digest_file(struct digest *d, char *filename,
-		       unsigned char *key, size_t keylen,
+int digest_file(struct digest *d, const char *filename,
+		       const unsigned char *key, size_t keylen,
 		       unsigned char *hash)
 {
 	struct stat st;
@@ -205,8 +205,8 @@ int digest_file(struct digest *d, char *filename,
 }
 EXPORT_SYMBOL_GPL(digest_file);
 
-int digest_file_by_name(char *algo, char *filename,
-		       unsigned char *key, size_t keylen,
+int digest_file_by_name(const char *algo, const char *filename,
+		       const unsigned char *key, size_t keylen,
 		       unsigned char *hash)
 {
 	struct digest *d;
diff --git a/include/digest.h b/include/digest.h
index fd47a7e..b890a7a 100644
--- a/include/digest.h
+++ b/include/digest.h
@@ -31,7 +31,7 @@ struct digest_algo {
 	int (*init)(struct digest *d);
 	int (*update)(struct digest *d, const void *data, unsigned long len);
 	int (*final)(struct digest *d, unsigned char *md);
-	int (*set_key)(struct digest *d, unsigned char *key, unsigned int len);
+	int (*set_key)(struct digest *d, const unsigned char *key, unsigned int len);
 
 	unsigned int length;
 	unsigned int ctx_length;
@@ -50,18 +50,18 @@ struct digest {
 int digest_algo_register(struct digest_algo *d);
 void digest_algo_unregister(struct digest_algo *d);
 
-struct digest *digest_alloc(char* name);
+struct digest *digest_alloc(const char *name);
 void digest_free(struct digest *d);
 
-int digest_file_window(struct digest *d, char *filename,
-		       unsigned char *key, size_t keylen,
+int digest_file_window(struct digest *d, const char *filename,
+		       const unsigned char *key, size_t keylen,
 		       unsigned char *hash,
 		       ulong start, ulong size);
-int digest_file(struct digest *d, char *filename,
-		       unsigned char *key, size_t keylen,
+int digest_file(struct digest *d, const char *filename,
+		       const unsigned char *key, size_t keylen,
 		       unsigned char *hash);
-int digest_file_by_name(char *algo, char *filename,
-		       unsigned char *key, size_t keylen,
+int digest_file_by_name(const char *algo, const char *filename,
+		       const unsigned char *key, size_t keylen,
 		       unsigned char *hash);
 
 static inline int digest_init(struct digest *d)
@@ -85,7 +85,8 @@ static inline int digest_length(struct digest *d)
 	return d->algo->length;
 }
 
-static inline int digest_set_key(struct digest *d, unsigned char *key, unsigned int len)
+static inline int digest_set_key(struct digest *d, const unsigned char *key,
+		unsigned int len)
 {
 	if (!d->algo->set_key)
 		return -ENOTSUPP;
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] crypto: digest: Fix coding style
  2015-03-12  7:17 [PATCH 1/2] crypto: digest: Make string arguments const Sascha Hauer
@ 2015-03-12  7:17 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-03-12  7:17 UTC (permalink / raw)
  To: Barebox List

When declaring pointer data or a function that returns a pointer type, the
preferred use of '*' is adjacent to the data name or function name and not
adjacent to the type name.

Fix the remaining occurences in crypto/

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 crypto/digest.c | 8 ++++----
 crypto/hmac.c   | 2 +-
 crypto/sha1.c   | 8 ++++----
 crypto/sha2.c   | 8 ++++----
 crypto/sha4.c   | 8 ++++----
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/crypto/digest.c b/crypto/digest.c
index 922d9d0..c06089d 100644
--- a/crypto/digest.c
+++ b/crypto/digest.c
@@ -28,7 +28,7 @@
 
 static LIST_HEAD(digests);
 
-static struct digest_algo* digest_algo_get_by_name(const char *name);
+static struct digest_algo *digest_algo_get_by_name(const char *name);
 
 static int dummy_init(struct digest *d)
 {
@@ -71,7 +71,7 @@ EXPORT_SYMBOL(digest_algo_unregister);
 
 static struct digest_algo *digest_algo_get_by_name(const char *name)
 {
-	struct digest_algo* d;
+	struct digest_algo *d;
 
 	if (!name)
 		return NULL;
@@ -86,8 +86,8 @@ static struct digest_algo *digest_algo_get_by_name(const char *name)
 
 struct digest *digest_alloc(const char *name)
 {
-	struct digest* d;
-	struct digest_algo* algo;
+	struct digest *d;
+	struct digest_algo *algo;
 
 	algo = digest_algo_get_by_name(name);
 	if (!algo)
diff --git a/crypto/hmac.c b/crypto/hmac.c
index a996f1e..b04dff1 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -20,7 +20,7 @@ struct digest_hmac_ctx {
 	unsigned int keylen;
 };
 
-static inline struct digest_hmac * to_digest_hmac(struct digest_algo *algo)
+static inline struct digest_hmac *to_digest_hmac(struct digest_algo *algo)
 {
 	return container_of(algo, struct digest_hmac, algo);
 }
diff --git a/crypto/sha1.c b/crypto/sha1.c
index 766e4ea..a244b5d 100644
--- a/crypto/sha1.c
+++ b/crypto/sha1.c
@@ -48,7 +48,7 @@ sha1_context;
 /*
  * SHA-1 context setup
  */
-static void sha1_starts (sha1_context * ctx)
+static void sha1_starts (sha1_context *ctx)
 {
 	ctx->total[0] = 0;
 	ctx->total[1] = 0;
@@ -60,7 +60,7 @@ static void sha1_starts (sha1_context * ctx)
 	ctx->state[4] = 0xC3D2E1F0;
 }
 
-static void sha1_process (sha1_context * ctx, uint8_t data[64])
+static void sha1_process (sha1_context *ctx, uint8_t data[64])
 {
 	uint32_t temp, W[16], A, B, C, D, E;
 
@@ -217,7 +217,7 @@ static void sha1_process (sha1_context * ctx, uint8_t data[64])
 /*
  * SHA-1 process buffer
  */
-static void sha1_update (sha1_context * ctx, uint8_t *input, uint32_t ilen)
+static void sha1_update (sha1_context *ctx, uint8_t *input, uint32_t ilen)
 {
 	uint32_t fill, left;
 
@@ -262,7 +262,7 @@ static uint8_t sha1_padding[64] = {
 /*
  * SHA-1 final digest
  */
-static void sha1_finish (sha1_context * ctx, uint8_t output[20])
+static void sha1_finish (sha1_context *ctx, uint8_t output[20])
 {
 	uint32_t last, padn;
 	uint32_t high, low;
diff --git a/crypto/sha2.c b/crypto/sha2.c
index 8558030..cb89c82 100644
--- a/crypto/sha2.c
+++ b/crypto/sha2.c
@@ -39,7 +39,7 @@ typedef struct {
 #define GET_UINT32_BE(n,b,i) (n) = be32_to_cpu(((uint32_t*)(b))[i / 4])
 #define PUT_UINT32_BE(n,b,i) ((uint32_t*)(b))[i / 4] = cpu_to_be32(n)
 
-static void sha2_starts(sha2_context * ctx, int is224)
+static void sha2_starts(sha2_context *ctx, int is224)
 {
 	ctx->total[0] = 0;
 	ctx->total[1] = 0;
@@ -74,7 +74,7 @@ static void sha2_starts(sha2_context * ctx, int is224)
 	ctx->is224 = is224;
 }
 
-static void sha2_process(sha2_context * ctx, const uint8_t data[64])
+static void sha2_process(sha2_context *ctx, const uint8_t data[64])
 {
 	uint32_t temp1, temp2;
 	uint32_t W[64];
@@ -205,7 +205,7 @@ static void sha2_process(sha2_context * ctx, const uint8_t data[64])
 	ctx->state[7] += H;
 }
 
-static void sha2_update(sha2_context * ctx, const uint8_t * input, size_t length)
+static void sha2_update(sha2_context *ctx, const uint8_t *input, size_t length)
 {
 	size_t fill;
 	uint32_t left;
@@ -247,7 +247,7 @@ static const uint8_t sha2_padding[64] = {
 	   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 };
 
-static void sha2_finish(sha2_context * ctx, uint8_t digest[32])
+static void sha2_finish(sha2_context *ctx, uint8_t digest[32])
 {
 	uint32_t last, padn;
 	uint32_t high, low;
diff --git a/crypto/sha4.c b/crypto/sha4.c
index 8a56081..1c768e7 100644
--- a/crypto/sha4.c
+++ b/crypto/sha4.c
@@ -97,7 +97,7 @@ static const uint64_t K[80] = {
 /*
  * SHA-512 context setup
  */
-static void sha4_starts(sha4_context * ctx, int is384)
+static void sha4_starts(sha4_context *ctx, int is384)
 {
 	ctx->total[0] = 0;
 	ctx->total[1] = 0;
@@ -127,7 +127,7 @@ static void sha4_starts(sha4_context * ctx, int is384)
 	ctx->is384 = is384;
 }
 
-static void sha4_process(sha4_context * ctx, unsigned char data[128])
+static void sha4_process(sha4_context *ctx, unsigned char data[128])
 {
 	int i;
 	uint64_t temp1, temp2, W[80];
@@ -202,7 +202,7 @@ static void sha4_process(sha4_context * ctx, unsigned char data[128])
 /*
  * SHA-512 process buffer
  */
-static void sha4_update(sha4_context * ctx, unsigned char *input, int ilen)
+static void sha4_update(sha4_context *ctx, unsigned char *input, int ilen)
 {
 	int fill;
 	uint64_t left;
@@ -250,7 +250,7 @@ static const unsigned char sha4_padding[128] = {
 /*
  * SHA-512 final digest
  */
-static void sha4_finish(sha4_context * ctx, unsigned char output[64])
+static void sha4_finish(sha4_context *ctx, unsigned char output[64])
 {
 	int last, padn;
 	uint64_t high, low;
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-12  7:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12  7:17 [PATCH 1/2] crypto: digest: Make string arguments const Sascha Hauer
2015-03-12  7:17 ` [PATCH 2/2] crypto: digest: Fix coding style Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox