From d2c0374297b7dd687a89227f3e77ff3f244da94b Mon Sep 17 00:00:00 2001 From: rlar Date: Mon, 29 Feb 2016 19:41:04 +0100 Subject: [PATCH] add (int) casts to some strlen() invocations to prevent warnings --- src/buf.c | 2 +- src/misc.c | 2 +- src/scan.l | 4 ++-- src/scanopt.c | 6 +++--- src/tables.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/buf.c b/src/buf.c index 5cfce60..c03b85f 100644 --- a/src/buf.c +++ b/src/buf.c @@ -143,7 +143,7 @@ struct Buf *buf_strnappend (struct Buf *buf, const char *str, int n) /* Appends characters in str to buf. */ struct Buf *buf_strappend (struct Buf *buf, const char *str) { - return buf_strnappend (buf, str, strlen (str)); + return buf_strnappend (buf, str, (int) strlen (str)); } /* appends "#define str def\n" */ diff --git a/src/misc.c b/src/misc.c index 37a52bb..0d93e4b 100644 --- a/src/misc.c +++ b/src/misc.c @@ -138,7 +138,7 @@ static void action_m4_define (const char *defname, const char * value) /* Append "new_text" to the running buffer. */ void add_action (const char *new_text) { - int len = strlen (new_text); + int len = (int) strlen (new_text); while (len + action_index >= action_size - 10 /* slop */ ) { int new_size = action_size * 2; diff --git a/src/scan.l b/src/scan.l index d2c21b3..59c2c19 100644 --- a/src/scan.l +++ b/src/scan.l @@ -272,8 +272,8 @@ M4QEND "]]" buf_strnappend(&top_buf, yytext, yyleng); } - {M4QSTART} buf_strnappend(&top_buf, escaped_qstart, strlen(escaped_qstart)); - {M4QEND} buf_strnappend(&top_buf, escaped_qend, strlen(escaped_qend)); + {M4QSTART} buf_strnappend(&top_buf, escaped_qstart, (int) strlen(escaped_qstart)); + {M4QEND} buf_strnappend(&top_buf, escaped_qend, (int) strlen(escaped_qend)); [^{}\r\n] { buf_strnappend(&top_buf, yytext, yyleng); diff --git a/src/scanopt.c b/src/scanopt.c index f173997..d829d0f 100644 --- a/src/scanopt.c +++ b/src/scanopt.c @@ -178,7 +178,7 @@ scanopt_t *scanopt_init (const optspec_t *options, int argc, char **argv, int fl pname = (const unsigned char *)(opt->opt_fmt + 1); s->has_short = 1; } - aux->printlen = strlen (opt->opt_fmt); + aux->printlen = (int) strlen (opt->opt_fmt); aux->namelen = 0; for (p = pname + 1; *p; p++) { @@ -359,7 +359,7 @@ int scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage) maxlen[0] = len; /* It's much easier to calculate length for description column! */ - len = strlen (DESC (s, ue->idx)); + len = (int) strlen (DESC (s, ue->idx)); if (len > maxlen[1]) maxlen[1] = len; } @@ -738,7 +738,7 @@ int scanopt (scanopt_t *svoid, char **arg, int *optindex) arglen = 0; } else - arglen = strlen (optarg); + arglen = (int) strlen (optarg); } /* At this point, we have a long or short option matched at opt_offset into diff --git a/src/tables.c b/src/tables.c index ae2ad9c..ff89b4d 100644 --- a/src/tables.c +++ b/src/tables.c @@ -158,12 +158,12 @@ int yytbl_hdr_fwrite (struct yytbl_writer *wr, const struct yytbl_hdr *th) flex_die (_("th_ssize|th_flags write failed")); bwritten += 6; - sz = strlen (th->th_version) + 1; + sz = (int) strlen (th->th_version) + 1; if ((rv = yytbl_writen (wr, th->th_version, sz)) != sz) flex_die (_("th_version writen failed")); bwritten += rv; - sz = strlen (th->th_name) + 1; + sz = (int) strlen (th->th_name) + 1; if ((rv = yytbl_writen (wr, th->th_name, sz)) != sz) flex_die (_("th_name writen failed")); bwritten += rv; -- 2.40.0