title: Problem with hashing function - C
body: <p>I am using the following hashing function provided in the K&amp;R book. </p>
  
  <pre><code>#define HASHSIZE 101
  unsigned hash(char *s)
  {
      unsigned hashval;
      for (hashval = 0; *s != '\0'; s++)
          hashval = *s + 31 * hashval;
      return hashval % HASHSIZE;
  }
  </code></pre>
  
  <p>In my project, I have more warnings turned on (warnings are treated as errors too) and the above code will fail to compile. </p>
  
  <pre><code>error: conversion to ‘unsigned int’ from ‘char’ may change the sign of the result
  </code></pre>
  
  <p>If I make the <code>hashval</code> signed, I am getting negative hash values. I am wondering how this can be fixed.</p>
  
  <p>Any help?</p>