From: Matthew Fernandez Date: Thu, 3 Nov 2022 04:41:33 +0000 (-0700) Subject: cdt: squash -Wconversion warning X-Git-Tag: 7.0.1~4^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a97b535cd279d36a34c9de982ce8886179c80751;p=graphviz cdt: squash -Wconversion warning This squashes the warning: dtstrhash.c: In function ‘dtstrhash’: dtstrhash.c:36:18: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion] 36 | return (h+n)*DT_PRIME; | ^ `n` is guaranteed non-negative by the logic preceding this. --- diff --git a/lib/cdt/dtstrhash.c b/lib/cdt/dtstrhash.c index 39f7089e4..2b65b11b9 100644 --- a/lib/cdt/dtstrhash.c +++ b/lib/cdt/dtstrhash.c @@ -33,5 +33,6 @@ uint dtstrhash(uint h, void* args, int n) if(s <= ends) h = (h + ((unsigned)s[0] << 8u)) * DT_PRIME; } - return (h+n)*DT_PRIME; + assert(n >= 0); + return (h + (unsigned)n) * DT_PRIME; }