From: Matthew Fernandez Date: Thu, 28 Jul 2022 02:05:51 +0000 (-0700) Subject: gvpr rindexOf: return a long instead of int X-Git-Tag: 5.0.1~25^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa2ea0fca16cc0131b82cdf51c9454a151019a5b;p=graphviz gvpr rindexOf: return a long instead of int The only use of this function stores the return value in a long, so lets just return a long, squashing two compiler warnings. --- diff --git a/lib/gvpr/actions.c b/lib/gvpr/actions.c index 1040a9ceb..6528d0421 100644 --- a/lib/gvpr/actions.c +++ b/lib/gvpr/actions.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -63,15 +64,17 @@ int indexOf(char *s1, char *s2) /* rindexOf: * Return index of rightmost string s2 in string s1, or -1 */ -int rindexOf(char *s1, char *s2) +long rindexOf(char *s1, char *s2) { char c1 = *s2; char *p; size_t len1 = strlen(s1); size_t len2 = strlen(s2); - if (c1 == '\0') - return (len1); + if (c1 == '\0') { + assert(len1 <= LONG_MAX); + return (long)len1; + } if (len2 > len1) return -1; p = s1 + (len1 - len2); diff --git a/lib/gvpr/actions.h b/lib/gvpr/actions.h index f7a2cb091..39dc11787 100644 --- a/lib/gvpr/actions.h +++ b/lib/gvpr/actions.h @@ -23,7 +23,7 @@ extern "C" { extern Agobj_t *copy(Agraph_t * g, Agobj_t * obj); extern int copyAttr(Agobj_t * obj, Agobj_t * obj1); extern int indexOf(char *s1, char *s2); - extern int rindexOf(char *s1, char *s2); + extern long rindexOf(char *s1, char *s2); extern int match(char *str, char *pat); extern int lockGraph(Agraph_t * g, int); extern Agraph_t *compOf(Agraph_t * g, Agnode_t * n);