On 6/30/26 18:04, Shahyan Soltani wrote:
> The num_fences, count, i, and j variables in dma_fence_dedup_array() and
> __dma_fence_unwrap_merge() have inconsistent integer types, mixing both
> unsigned int and int.
>
> Use type size_t consistently for these instead, and update the return
> type of dma_fence_dedup_array() accordingly.
>
> Signed-off-by: Shahyan Soltani <[email protected]>
> Suggested-by: Philipp Stanner <[email protected]>
Reviewed and pushed to drm-misc-next.
Thanks,
Christian.
> ---
> The rest of the subsystems (dma_resv_reserve_fences, drm_exec, drm_gpuvm,
> xe, nouveau, etc) uses "unsigned int" for num_fences, for example the
> amdgpu caller in amdgpu_userq_fence.c.
>
> drivers/dma-buf/dma-fence-unwrap.c | 8 ++++----
> include/linux/dma-fence-unwrap.h | 6 ++++--
> 2 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence-unwrap.c
> b/drivers/dma-buf/dma-fence-unwrap.c
> index 53bb40e70b27..65e87d263c3a 100644
> --- a/drivers/dma-buf/dma-fence-unwrap.c
> +++ b/drivers/dma-buf/dma-fence-unwrap.c
> @@ -93,9 +93,9 @@ static int fence_cmp(const void *_a, const void *_b)
> *
> * Return: Number of unique fences remaining in the array.
> */
> -int dma_fence_dedup_array(struct dma_fence **fences, int num_fences)
> +size_t dma_fence_dedup_array(struct dma_fence **fences, size_t num_fences)
> {
> - int i, j;
> + size_t i, j;
>
> sort(fences, num_fences, sizeof(*fences), fence_cmp, NULL);
>
> @@ -115,14 +115,14 @@ int dma_fence_dedup_array(struct dma_fence **fences,
> int num_fences)
> EXPORT_SYMBOL_GPL(dma_fence_dedup_array);
>
> /* Implementation for the dma_fence_merge() marco, don't use directly */
> -struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences,
> +struct dma_fence *__dma_fence_unwrap_merge(size_t num_fences,
> struct dma_fence **fences,
> struct dma_fence_unwrap *iter)
> {
> struct dma_fence *tmp, *unsignaled = NULL, **array;
> struct dma_fence_array *result;
> ktime_t timestamp;
> - int i, count;
> + size_t i, count;
>
> count = 0;
> timestamp = ns_to_ktime(0);
> diff --git a/include/linux/dma-fence-unwrap.h
> b/include/linux/dma-fence-unwrap.h
> index 62df222fe0f1..7bfacdf79de2 100644
> --- a/include/linux/dma-fence-unwrap.h
> +++ b/include/linux/dma-fence-unwrap.h
> @@ -8,6 +8,8 @@
> #ifndef __LINUX_DMA_FENCE_UNWRAP_H
> #define __LINUX_DMA_FENCE_UNWRAP_H
>
> +#include <linux/types.h>
> +
> struct dma_fence;
>
> /**
> @@ -48,11 +50,11 @@ struct dma_fence *dma_fence_unwrap_next(struct
> dma_fence_unwrap *cursor);
> for (fence = dma_fence_unwrap_first(head, cursor); fence; \
> fence = dma_fence_unwrap_next(cursor))
>
> -struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences,
> +struct dma_fence *__dma_fence_unwrap_merge(size_t num_fences,
> struct dma_fence **fences,
> struct dma_fence_unwrap *cursors);
>
> -int dma_fence_dedup_array(struct dma_fence **array, int num_fences);
> +size_t dma_fence_dedup_array(struct dma_fence **array, size_t num_fences);
>
> /**
> * dma_fence_unwrap_merge - unwrap and merge fences