fixes #676 MSVC x64 reports compiler warnings in nanocat
diff --git a/tools/options.c b/tools/options.c
index 1b4ad99..98893c7 100644
--- a/tools/options.c
+++ b/tools/options.c
@@ -26,7 +26,6 @@
#include <string.h>
#include <stdio.h>
-#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <ctype.h>
@@ -134,14 +133,14 @@
static char *nn_print_line (FILE *out, char *str, size_t width)
{
- int i;
+ size_t i;
if (strlen (str) < width) {
fprintf (out, "%s", str);
return "";
}
for (i = width; i > 1; --i) {
if (isspace (str[i])) {
- fprintf (out, "%.*s", i, str);
+ fprintf (out, "%.*s", (int) i, str);
return str + i + 1;
}
} /* no break points, just print as is */
@@ -152,7 +151,7 @@
static void nn_print_help (struct nn_parse_context *ctx, FILE *stream)
{
int i;
- int optlen;
+ size_t optlen;
struct nn_option *opt;
char *last_group;
char *cursor;
@@ -381,7 +380,7 @@
char *data;
size_t data_len;
size_t data_buf;
- int bytes_read;
+ size_t bytes_read;
opt = &ctx->options[opt_index];
if (ctx->mask & opt->conflicts_mask) {
@@ -603,8 +602,8 @@
{
struct nn_option *opt;
char *a, *b;
- int longest_prefix;
- int cur_prefix;
+ size_t longest_prefix;
+ size_t cur_prefix;
int best_match;
char *arg;
int i;
diff --git a/tools/options.h b/tools/options.h
index fb8f41e..0c865cf 100644
--- a/tools/options.h
+++ b/tools/options.h
@@ -23,6 +23,8 @@
#ifndef NN_OPTIONS_HEADER
#define NN_OPTIONS_HEADER
+#include <stdlib.h>
+
enum nn_option_type {
NN_OPT_HELP,
NN_OPT_INT,
@@ -81,7 +83,7 @@
struct nn_blob {
char *data;
- int length;
+ size_t length;
int need_free;
};