Skip to content

Commit 28e75c5

Browse files
mattnchrisbra
authored andcommitted
patch 9.2.0286: still some unnecessary (int) casts in alloc()
Problem: still some unnecessary (int) casts in alloc() Solution: Remove more unnecessary (int) casts before alloc() calls (Yasuhiro Matsumoto). Follow-up to patch 9.2.0283. Remove remaining (int) casts in vim9script.c and netbeans.c. vim9script.c: lengths are derived from STRLEN() on file paths, bounded by PATH_MAX. netbeans.c: all operands are already int, so the (int) cast is redundant and no truncation can occur. related: #19888 closes: #19893 Signed-off-by: Yasuhiro Matsumoto <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent b7cffc8 commit 28e75c5

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/netbeans.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ nb_partialremove(linenr_T lnum, colnr_T first, colnr_T last)
937937
return;
938938
if (lastbyte >= oldlen)
939939
lastbyte = oldlen - 1;
940-
newtext = alloc(oldlen - (int)(lastbyte - first));
940+
newtext = alloc(oldlen - (lastbyte - first));
941941
if (newtext == NULL)
942942
return;
943943

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
286,
737739
/**/
738740
285,
739741
/**/

src/vim9script.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ handle_import(
460460
{
461461
// Relative to current script: "./name.vim", "../../name.vim".
462462
len = STRLEN(si->sn_name) - STRLEN(tail) + STRLEN(tv.vval.v_string) + 2;
463-
from_name = alloc((int)len);
463+
from_name = alloc(len);
464464
if (from_name == NULL)
465465
goto erret;
466466
vim_strncpy(from_name, si->sn_name, tail - si->sn_name);
@@ -485,7 +485,7 @@ handle_import(
485485
char_u *from_name;
486486

487487
// Find file in "autoload" subdirs in 'runtimepath'.
488-
from_name = alloc((int)len);
488+
from_name = alloc(len);
489489
if (from_name == NULL)
490490
goto erret;
491491
vim_snprintf((char *)from_name, len, "autoload/%s", tv.vval.v_string);
@@ -512,7 +512,7 @@ handle_import(
512512
char_u *from_name;
513513

514514
// Find file in "import" subdirs in 'runtimepath'.
515-
from_name = alloc((int)len);
515+
from_name = alloc(len);
516516
if (from_name == NULL)
517517
goto erret;
518518
vim_snprintf((char *)from_name, len, "import/%s", tv.vval.v_string);

0 commit comments

Comments
 (0)