[PATCH] lib/xxhash: remove more unused xxh functions

linux@treblig.org posted 1 patch 3 months, 2 weeks ago
include/linux/xxhash.h | 46 +-----------------------------------------
lib/xxhash.c           | 29 --------------------------
2 files changed, 1 insertion(+), 74 deletions(-)
[PATCH] lib/xxhash: remove more unused xxh functions
Posted by linux@treblig.org 3 months, 2 weeks ago
From: "Dr. David Alan Gilbert" <linux@treblig.org>

xxh32_reset() and xxh32_copy_state() are unused, and with those gone,
the xxh32_state struct is also unused.

xxh64_copy_state() is also unused.

Remove them all.

(Also fixes a comment above the xxh64_state that referred to it as
xxh32_state).

Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
 include/linux/xxhash.h | 46 +-----------------------------------------
 lib/xxhash.c           | 29 --------------------------
 2 files changed, 1 insertion(+), 74 deletions(-)

diff --git a/include/linux/xxhash.h b/include/linux/xxhash.h
index 27f57eca8cb1..587122e2c29c 100644
--- a/include/linux/xxhash.h
+++ b/include/linux/xxhash.h
@@ -141,21 +141,7 @@ static inline unsigned long xxhash(const void *input, size_t length,
  */
 
 /**
- * struct xxh32_state - private xxh32 state, do not use members directly
- */
-struct xxh32_state {
-	uint32_t total_len_32;
-	uint32_t large_len;
-	uint32_t v1;
-	uint32_t v2;
-	uint32_t v3;
-	uint32_t v4;
-	uint32_t mem32[4];
-	uint32_t memsize;
-};
-
-/**
- * struct xxh32_state - private xxh64 state, do not use members directly
+ * struct xxh64_state - private xxh64 state, do not use members directly
  */
 struct xxh64_state {
 	uint64_t total_len;
@@ -167,16 +153,6 @@ struct xxh64_state {
 	uint32_t memsize;
 };
 
-/**
- * xxh32_reset() - reset the xxh32 state to start a new hashing operation
- *
- * @state: The xxh32 state to reset.
- * @seed:  Initialize the hash state with this seed.
- *
- * Call this function on any xxh32_state to prepare for a new hashing operation.
- */
-void xxh32_reset(struct xxh32_state *state, uint32_t seed);
-
 /**
  * xxh64_reset() - reset the xxh64 state to start a new hashing operation
  *
@@ -210,24 +186,4 @@ int xxh64_update(struct xxh64_state *state, const void *input, size_t length);
  */
 uint64_t xxh64_digest(const struct xxh64_state *state);
 
-/*-**************************
- * Utils
- ***************************/
-
-/**
- * xxh32_copy_state() - copy the source state into the destination state
- *
- * @src: The source xxh32 state.
- * @dst: The destination xxh32 state.
- */
-void xxh32_copy_state(struct xxh32_state *dst, const struct xxh32_state *src);
-
-/**
- * xxh64_copy_state() - copy the source state into the destination state
- *
- * @src: The source xxh64 state.
- * @dst: The destination xxh64 state.
- */
-void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state *src);
-
 #endif /* XXHASH_H */
diff --git a/lib/xxhash.c b/lib/xxhash.c
index cf629766f376..4125b3e3cf7f 100644
--- a/lib/xxhash.c
+++ b/lib/xxhash.c
@@ -73,21 +73,6 @@ static const uint64_t PRIME64_3 =  1609587929392839161ULL;
 static const uint64_t PRIME64_4 =  9650029242287828579ULL;
 static const uint64_t PRIME64_5 =  2870177450012600261ULL;
 
-/*-**************************
- *  Utils
- ***************************/
-void xxh32_copy_state(struct xxh32_state *dst, const struct xxh32_state *src)
-{
-	memcpy(dst, src, sizeof(*dst));
-}
-EXPORT_SYMBOL(xxh32_copy_state);
-
-void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state *src)
-{
-	memcpy(dst, src, sizeof(*dst));
-}
-EXPORT_SYMBOL(xxh64_copy_state);
-
 /*-***************************
  * Simple Hash Functions
  ****************************/
@@ -239,20 +224,6 @@ EXPORT_SYMBOL(xxh64);
 /*-**************************************************
  * Advanced Hash Functions
  ***************************************************/
-void xxh32_reset(struct xxh32_state *statePtr, const uint32_t seed)
-{
-	/* use a local state for memcpy() to avoid strict-aliasing warnings */
-	struct xxh32_state state;
-
-	memset(&state, 0, sizeof(state));
-	state.v1 = seed + PRIME32_1 + PRIME32_2;
-	state.v2 = seed + PRIME32_2;
-	state.v3 = seed + 0;
-	state.v4 = seed - PRIME32_1;
-	memcpy(statePtr, &state, sizeof(state));
-}
-EXPORT_SYMBOL(xxh32_reset);
-
 void xxh64_reset(struct xxh64_state *statePtr, const uint64_t seed)
 {
 	/* use a local state for memcpy() to avoid strict-aliasing warnings */
-- 
2.51.0
Re: [PATCH] lib/xxhash: remove more unused xxh functions
Posted by Kuan-Wei Chiu 3 months, 1 week ago
On Fri, Oct 24, 2025 at 09:51:20PM +0100, linux@treblig.org wrote:
> From: "Dr. David Alan Gilbert" <linux@treblig.org>
> 
> xxh32_reset() and xxh32_copy_state() are unused, and with those gone,
> the xxh32_state struct is also unused.
> 
> xxh64_copy_state() is also unused.
> 
> Remove them all.
> 
> (Also fixes a comment above the xxh64_state that referred to it as
> xxh32_state).
> 
> Suggested-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>

FWIW,

Reviewed-by: Kuan-Wei Chiu <visitorckw@gmail.com>

Regards,
Kuan-Wei

> ---
>  include/linux/xxhash.h | 46 +-----------------------------------------
>  lib/xxhash.c           | 29 --------------------------
>  2 files changed, 1 insertion(+), 74 deletions(-)
> 
> diff --git a/include/linux/xxhash.h b/include/linux/xxhash.h
> index 27f57eca8cb1..587122e2c29c 100644
> --- a/include/linux/xxhash.h
> +++ b/include/linux/xxhash.h
> @@ -141,21 +141,7 @@ static inline unsigned long xxhash(const void *input, size_t length,
>   */
>  
>  /**
> - * struct xxh32_state - private xxh32 state, do not use members directly
> - */
> -struct xxh32_state {
> -	uint32_t total_len_32;
> -	uint32_t large_len;
> -	uint32_t v1;
> -	uint32_t v2;
> -	uint32_t v3;
> -	uint32_t v4;
> -	uint32_t mem32[4];
> -	uint32_t memsize;
> -};
> -
> -/**
> - * struct xxh32_state - private xxh64 state, do not use members directly
> + * struct xxh64_state - private xxh64 state, do not use members directly
>   */
>  struct xxh64_state {
>  	uint64_t total_len;
> @@ -167,16 +153,6 @@ struct xxh64_state {
>  	uint32_t memsize;
>  };
>  
> -/**
> - * xxh32_reset() - reset the xxh32 state to start a new hashing operation
> - *
> - * @state: The xxh32 state to reset.
> - * @seed:  Initialize the hash state with this seed.
> - *
> - * Call this function on any xxh32_state to prepare for a new hashing operation.
> - */
> -void xxh32_reset(struct xxh32_state *state, uint32_t seed);
> -
>  /**
>   * xxh64_reset() - reset the xxh64 state to start a new hashing operation
>   *
> @@ -210,24 +186,4 @@ int xxh64_update(struct xxh64_state *state, const void *input, size_t length);
>   */
>  uint64_t xxh64_digest(const struct xxh64_state *state);
>  
> -/*-**************************
> - * Utils
> - ***************************/
> -
> -/**
> - * xxh32_copy_state() - copy the source state into the destination state
> - *
> - * @src: The source xxh32 state.
> - * @dst: The destination xxh32 state.
> - */
> -void xxh32_copy_state(struct xxh32_state *dst, const struct xxh32_state *src);
> -
> -/**
> - * xxh64_copy_state() - copy the source state into the destination state
> - *
> - * @src: The source xxh64 state.
> - * @dst: The destination xxh64 state.
> - */
> -void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state *src);
> -
>  #endif /* XXHASH_H */
> diff --git a/lib/xxhash.c b/lib/xxhash.c
> index cf629766f376..4125b3e3cf7f 100644
> --- a/lib/xxhash.c
> +++ b/lib/xxhash.c
> @@ -73,21 +73,6 @@ static const uint64_t PRIME64_3 =  1609587929392839161ULL;
>  static const uint64_t PRIME64_4 =  9650029242287828579ULL;
>  static const uint64_t PRIME64_5 =  2870177450012600261ULL;
>  
> -/*-**************************
> - *  Utils
> - ***************************/
> -void xxh32_copy_state(struct xxh32_state *dst, const struct xxh32_state *src)
> -{
> -	memcpy(dst, src, sizeof(*dst));
> -}
> -EXPORT_SYMBOL(xxh32_copy_state);
> -
> -void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state *src)
> -{
> -	memcpy(dst, src, sizeof(*dst));
> -}
> -EXPORT_SYMBOL(xxh64_copy_state);
> -
>  /*-***************************
>   * Simple Hash Functions
>   ****************************/
> @@ -239,20 +224,6 @@ EXPORT_SYMBOL(xxh64);
>  /*-**************************************************
>   * Advanced Hash Functions
>   ***************************************************/
> -void xxh32_reset(struct xxh32_state *statePtr, const uint32_t seed)
> -{
> -	/* use a local state for memcpy() to avoid strict-aliasing warnings */
> -	struct xxh32_state state;
> -
> -	memset(&state, 0, sizeof(state));
> -	state.v1 = seed + PRIME32_1 + PRIME32_2;
> -	state.v2 = seed + PRIME32_2;
> -	state.v3 = seed + 0;
> -	state.v4 = seed - PRIME32_1;
> -	memcpy(statePtr, &state, sizeof(state));
> -}
> -EXPORT_SYMBOL(xxh32_reset);
> -
>  void xxh64_reset(struct xxh64_state *statePtr, const uint64_t seed)
>  {
>  	/* use a local state for memcpy() to avoid strict-aliasing warnings */
> -- 
> 2.51.0
> 
>
Re: [PATCH] lib/xxhash: remove more unused xxh functions
Posted by Christoph Hellwig 3 months, 1 week ago
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

(just sending patches to one of my email addresses if preferred, I don't
care which one).