This squashes the warning:
dtstrhash.c:23:21: warning: conversion from ‘long int’ to ‘int’ may change
value [-Wconversion]
23 | n = s - (unsigned char*)args;
| ^
This cast is mostly guaranteed safe by the inability to practically pass a
>INT_MAX length string into this function.
+#include <assert.h>
#include <cdt/dthdr.h>
+#include <limits.h>
+#include <string.h>
/* Hashing a string into an unsigned integer.
** The basic method is to continuingly accumulate bytes and multiply
if(n <= 0)
{ for(; *s != 0; s += s[1] ? 2 : 1)
h = (h + ((unsigned)s[0] << 8u) + (unsigned)s[1]) * DT_PRIME;
- n = s - (unsigned char*)args;
+ assert(strlen(args) <= INT_MAX);
+ n = (int)(s - (unsigned char*)args);
}
else
{ unsigned char* ends;