Fossil SCM

Fix a harmless UBSAN warning in makeheaders.c

drh 2025-10-08 14:40 trunk
Commit a456dcbbac25366ccb02696505ea04e99dace78ceb81056f7fc91537d3b14cc4
1 file changed +2 -2
--- tools/makeheaders.c
+++ tools/makeheaders.c
@@ -486,18 +486,18 @@
486486
/*
487487
** Compute a hash on a string. The number returned is a non-negative
488488
** value between 0 and 2**31 - 1
489489
*/
490490
static int Hash(const char *z, int n){
491
- int h = 0;
491
+ unsigned int h = 0;
492492
if( n<=0 ){
493493
n = strlen(z);
494494
}
495495
while( n-- ){
496496
h = h ^ (h<<5) ^ *z++;
497497
}
498
- return h & 0x7fffffff;
498
+ return (int)(h & 0x7fffffff);
499499
}
500500
501501
/*
502502
** Given an identifier name, try to find a declaration for that
503503
** identifier in the hash table. If found, return a pointer to
504504
--- tools/makeheaders.c
+++ tools/makeheaders.c
@@ -486,18 +486,18 @@
486 /*
487 ** Compute a hash on a string. The number returned is a non-negative
488 ** value between 0 and 2**31 - 1
489 */
490 static int Hash(const char *z, int n){
491 int h = 0;
492 if( n<=0 ){
493 n = strlen(z);
494 }
495 while( n-- ){
496 h = h ^ (h<<5) ^ *z++;
497 }
498 return h & 0x7fffffff;
499 }
500
501 /*
502 ** Given an identifier name, try to find a declaration for that
503 ** identifier in the hash table. If found, return a pointer to
504
--- tools/makeheaders.c
+++ tools/makeheaders.c
@@ -486,18 +486,18 @@
486 /*
487 ** Compute a hash on a string. The number returned is a non-negative
488 ** value between 0 and 2**31 - 1
489 */
490 static int Hash(const char *z, int n){
491 unsigned int h = 0;
492 if( n<=0 ){
493 n = strlen(z);
494 }
495 while( n-- ){
496 h = h ^ (h<<5) ^ *z++;
497 }
498 return (int)(h & 0x7fffffff);
499 }
500
501 /*
502 ** Given an identifier name, try to find a declaration for that
503 ** identifier in the hash table. If found, return a pointer to
504

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button