Commit 03fb6fe6 authored by Martin Milata's avatar Martin Milata Committed by Rusty Russell

base64: fix assignment to wrong type, use ssize_t

Functions that returned int have been modified to return ssize_t
instead.

Found by gcc:

base64.c:196:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (more == -1) {
           ^
Signed-off-by: default avatarMartin Milata <martin@martinmilata.cz>
parent ae967050
......@@ -118,7 +118,7 @@ size_t base64_decoded_length(size_t srclen)
return ((srclen+3)/4*3);
}
int base64_decode_quartet_using_maps(const base64_maps_t *maps, char dest[3],
ssize_t base64_decode_quartet_using_maps(const base64_maps_t *maps, char dest[3],
const char src[4])
{
signed char a;
......@@ -143,7 +143,7 @@ int base64_decode_quartet_using_maps(const base64_maps_t *maps, char dest[3],
}
int base64_decode_tail_using_maps(const base64_maps_t *maps, char dest[3],
ssize_t base64_decode_tail_using_maps(const base64_maps_t *maps, char dest[3],
const char * src, const size_t srclen)
{
char longsrc[4];
......@@ -178,7 +178,7 @@ ssize_t base64_decode_using_maps(const base64_maps_t *maps,
{
ssize_t dest_offset = 0;
ssize_t i;
size_t more;
ssize_t more;
if (destlen < base64_decoded_length(srclen)) {
errno = EOVERFLOW;
......
......@@ -103,7 +103,7 @@ ssize_t base64_decode_using_maps(const base64_maps_t *maps,
* @return Number of decoded bytes set in dest. -1 on error (and errno set)
* @note sets errno = EDOM if src contains invalid characters
*/
int base64_decode_quartet_using_maps(const base64_maps_t *maps,
ssize_t base64_decode_quartet_using_maps(const base64_maps_t *maps,
char dest[3], const char src[4]);
/**
......@@ -116,7 +116,7 @@ int base64_decode_quartet_using_maps(const base64_maps_t *maps,
* @note sets errno = EDOM if src contains invalid characters
* @note sets errno = EINVAL if src is an invalid base64 tail
*/
int base64_decode_tail_using_maps(const base64_maps_t *maps, char *dest,
ssize_t base64_decode_tail_using_maps(const base64_maps_t *maps, char *dest,
const char *src, size_t srclen);
......@@ -212,7 +212,7 @@ ssize_t base64_decode(char *dest, size_t destlen,
* @note sets errno = EDOM if src contains invalid characters
*/
static inline
int base64_decode_quartet(char dest[3], const char src[4])
ssize_t base64_decode_quartet(char dest[3], const char src[4])
{
return base64_decode_quartet_using_maps(&base64_maps_rfc4648,
dest, src);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment