On 8/7/14 5:58 PM, Branko Čibej wrote: > I've seen platforms where size_t was smaller than ptrdiff_t; but usually > they're the same size. The rules of type promotion in C state that an a value > of a signed type can be promoted to a value of the same-sized unsigned type > without truncation, whereas the opposite is not true. That's why you don't get > warnings here on most usual platforms. But the unusual platforms where size_t > is smaller than ptrdiff_t could be a problem.
I'm not going signed -> unsigned. I'm going unsigned -> signed (specifically apr_size_t to ptrdiff_t). Specifically: [[[ svn_error_t * svn_x509_parse_cert(svn_x509_certinfo_t **certinfo, const char *buf, apr_size_t buflen, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_error_t *err; ptrdiff_t len; const unsigned char *p; const unsigned char *end; x509_cert *crt; svn_x509_certinfo_t *ci; svn_stringbuf_t *namebuf; crt = apr_pcalloc(scratch_pool, sizeof(*crt)); p = (const unsigned char *)buf; len = buflen; end = p + len; ]]] Note the next to last line where I assign the ptrdiff_t len with the value from the apr_size_t buflen. Unless I'm missing something that ought to be producing a warning should it not?