Commit abe959a3 authored by Niels Möller's avatar Niels Möller

Fix pointer sign warnings in sexp_vformat.

parent 59ec2fc8
2016-08-29 Niels Möller <nisse@lysator.liu.se>
* sexp-format.c (strlen_u8): New helper function.
(sexp_vformat): Use uint8_t * for strings instead of char *.
2016-08-16 Niels Möller <nisse@lysator.liu.se> 2016-08-16 Niels Möller <nisse@lysator.liu.se>
* examples/io.c (hash_file): Use uint8_t for buffer. * examples/io.c (hash_file): Use uint8_t for buffer.
......
...@@ -90,6 +90,12 @@ format_string(struct nettle_buffer *buffer, ...@@ -90,6 +90,12 @@ format_string(struct nettle_buffer *buffer,
return prefix_length + length; return prefix_length + length;
} }
static inline size_t
strlen_u8 (const uint8_t *s)
{
return strlen((const char*) s);
}
size_t size_t
sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args) sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args)
{ {
...@@ -103,7 +109,8 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args) ...@@ -103,7 +109,8 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args)
{ {
const char *start = format - 1; const char *start = format - 1;
size_t length = 1 + strcspn(format, "()% \t"); size_t length = 1 + strcspn(format, "()% \t");
size_t output_length = format_string(buffer, length, start); size_t output_length
= format_string(buffer, length, (const uint8_t *) start);
if (!output_length) if (!output_length)
return 0; return 0;
...@@ -161,19 +168,19 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args) ...@@ -161,19 +168,19 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args)
case 's': case 's':
{ {
const char *s; const uint8_t *s;
size_t length; size_t length;
size_t output_length; size_t output_length;
if (nul_flag) if (nul_flag)
{ {
s = va_arg(args, const char *); s = va_arg(args, const uint8_t *);
length = strlen(s); length = strlen_u8(s);
} }
else else
{ {
length = va_arg(args, size_t); length = va_arg(args, size_t);
s = va_arg(args, const char *); s = va_arg(args, const uint8_t *);
} }
output_length = format_string(buffer, length, s); output_length = format_string(buffer, length, s);
...@@ -185,22 +192,22 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args) ...@@ -185,22 +192,22 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args)
} }
case 't': case 't':
{ {
const char *s; const uint8_t *s;
size_t length; size_t length;
size_t output_length; size_t output_length;
if (nul_flag) if (nul_flag)
{ {
s = va_arg(args, const char *); s = va_arg(args, const uint8_t *);
if (!s) if (!s)
break; break;
length = strlen(s); length = strlen_u8(s);
} }
else else
{ {
length = va_arg(args, size_t); length = va_arg(args, size_t);
s = va_arg(args, const char *); s = va_arg(args, const uint8_t *);
if (!s) if (!s)
break; break;
} }
...@@ -225,18 +232,18 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args) ...@@ -225,18 +232,18 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args)
case 'l': case 'l':
{ {
const char *s; const uint8_t *s;
size_t length; size_t length;
if (nul_flag) if (nul_flag)
{ {
s = va_arg(args, const char *); s = va_arg(args, const uint8_t *);
length = strlen(s); length = strlen_u8(s);
} }
else else
{ {
length = va_arg(args, size_t); length = va_arg(args, size_t);
s = va_arg(args, const char *); s = va_arg(args, const uint8_t *);
} }
if (buffer && !nettle_buffer_write(buffer, length, s)) if (buffer && !nettle_buffer_write(buffer, length, s))
......
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