diff src/if_cscope.c @ 16764:ef00b6bc186b v8.1.1384

patch 8.1.1384: using "int" for alloc() often results in compiler warnings commit https://github.com/vim/vim/commit/964b3746b9c81e65887e2ac9a335f181db2bb592 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 24 18:54:09 2019 +0200 patch 8.1.1384: using "int" for alloc() often results in compiler warnings Problem: Using "int" for alloc() often results in compiler warnings. Solution: Use "size_t" and remove type casts. Remove alloc_check(), Vim only works with 32 bit ints anyway.
author Bram Moolenaar <Bram@vim.org>
date Fri, 24 May 2019 19:00:07 +0200
parents b52ea9c5f1db
children ce04ebdf26b8
line wrap: on
line diff
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -466,7 +466,7 @@ cs_add(exarg_T *eap UNUSED)
 cs_stat_emsg(char *fname)
 {
     char *stat_emsg = _("E563: stat(%s) error: %d");
-    char *buf = (char *)alloc((unsigned)strlen(stat_emsg) + MAXPATHL + 10);
+    char *buf = (char *)alloc(strlen(stat_emsg) + MAXPATHL + 10);
 
     if (buf != NULL)
     {
@@ -543,7 +543,7 @@ staterr:
     /* if filename is a directory, append the cscope database name to it */
     if (S_ISDIR(statbuf.st_mode))
     {
-	fname2 = (char *)alloc((unsigned)(strlen(CSCOPE_DBFILE) + strlen(fname) + 2));
+	fname2 = (char *)alloc(strlen(CSCOPE_DBFILE) + strlen(fname) + 2);
 	if (fname2 == NULL)
 	    goto add_err;
 
@@ -769,7 +769,7 @@ cs_create_cmd(char *csoption, char *patt
 	while VIM_ISWHITE(*pat)
 	    ++pat;
 
-    if ((cmd = (char *)alloc((unsigned)(strlen(pat) + 2))) == NULL)
+    if ((cmd = (char *)alloc(strlen(pat) + 2)) == NULL)
 	return NULL;
 
     (void)sprintf(cmd, "%d%s", search, pat);
@@ -1121,7 +1121,7 @@ cs_find_common(
 	if (strchr(CSQF_FLAGS, *qfpos) == NULL)
 	{
 	    char *nf = _("E469: invalid cscopequickfix flag %c for %c");
-	    char *buf = (char *)alloc((unsigned)strlen(nf));
+	    char *buf = (char *)alloc(strlen(nf));
 
 	    /* strlen will be enough because we use chars */
 	    if (buf != NULL)
@@ -1192,7 +1192,7 @@ cs_find_common(
 	    return FALSE;
 	}
 
-	buf = (char *)alloc((unsigned)(strlen(opt) + strlen(pat) + strlen(nf)));
+	buf = (char *)alloc(strlen(opt) + strlen(pat) + strlen(nf));
 	if (buf == NULL)
 	    (void)emsg(nf);
 	else
@@ -1450,14 +1450,14 @@ cs_insert_filelist(
 	    clear_csinfo(j);
     }
 
-    if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
+    if ((csinfo[i].fname = (char *)alloc(strlen(fname)+1)) == NULL)
 	return -1;
 
     (void)strcpy(csinfo[i].fname, (const char *)fname);
 
     if (ppath != NULL)
     {
-	if ((csinfo[i].ppath = (char *)alloc((unsigned)strlen(ppath) + 1)) == NULL)
+	if ((csinfo[i].ppath = (char *)alloc(strlen(ppath) + 1)) == NULL)
 	{
 	    VIM_CLEAR(csinfo[i].fname);
 	    return -1;
@@ -1468,7 +1468,7 @@ cs_insert_filelist(
 
     if (flags != NULL)
     {
-	if ((csinfo[i].flags = (char *)alloc((unsigned)strlen(flags) + 1)) == NULL)
+	if ((csinfo[i].flags = (char *)alloc(strlen(flags) + 1)) == NULL)
 	{
 	    VIM_CLEAR(csinfo[i].fname);
 	    VIM_CLEAR(csinfo[i].ppath);
@@ -1820,7 +1820,7 @@ cs_file_results(FILE *f, int *nummatches
 			   &slno, &search)) == NULL)
 	       continue;
 
-	   context = (char *)alloc((unsigned)strlen(cntx)+5);
+	   context = (char *)alloc(strlen(cntx)+5);
 	   if (context == NULL)
 	       continue;
 
@@ -1975,7 +1975,7 @@ cs_print_tags_priv(char **matches, char 
 
     assert(num_matches > 0);
 
-    if ((tbuf = (char *)alloc((unsigned)strlen(matches[0]) + 1)) == NULL)
+    if ((tbuf = (char *)alloc(strlen(matches[0]) + 1)) == NULL)
 	return;
 
     strcpy(tbuf, matches[0]);
@@ -2010,7 +2010,7 @@ cs_print_tags_priv(char **matches, char 
 	 * by parsing matches[i] on the fly and placing stuff into buf
 	 * directly, but that's too much of a hassle
 	 */
-	if ((tbuf = (char *)alloc((unsigned)strlen(matches[idx]) + 1)) == NULL)
+	if ((tbuf = (char *)alloc(strlen(matches[idx]) + 1)) == NULL)
 	    continue;
 	(void)strcpy(tbuf, matches[idx]);