Skip to content

Commit

Permalink
Fix compiler warnings and regression test failure (re: fc2d5a6)
Browse files Browse the repository at this point in the history
src/cmd/ksh93/bltins/test.c:
- Fix the following compiler warnings from clang:
  test.c:554:11: warning: assigning to 'char *' from 'const char []'
  discards qualifiers
  [-Wincompatible-pointer-types-discards-qualifiers]
                                e_msg = e_badop;
                                      ^ ~~~~~~~
  test.c:556:11: warning: assigning to 'char *' from 'const char []'
  discards qualifiers
  [-Wincompatible-pointer-types-discards-qualifiers]
                                e_msg = e_unsupported_op;
                                      ^ ~~~~~~~~~~~~~~~~
  test.c:560:1: warning: control may reach end of non-void function
  [-Wreturn-type]

src/cmd/ksh93/tests/builtins.sh:
- Fix regression test by updating error message text.
  • Loading branch information
McDutchie committed Mar 27, 2021
1 parent fc2d5a6 commit f8de1f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/cmd/ksh93/bltins/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,16 +547,13 @@ int test_binop(Shell_t *shp,register int op,const char *left,const char *right)
{
/* fallback for operators not supported by the test builtin */
int i=0;
char *e_msg;
while(shtab_testops[i].sh_number && shtab_testops[i].sh_number != op)
i++;
if(op==TEST_END)
e_msg = e_badop;
else
e_msg = e_unsupported_op;
errormsg(SH_DICT,ERROR_exit(2),e_msg,shtab_testops[i].sh_name);
errormsg(SH_DICT, ERROR_exit(2), op==TEST_END ? e_badop : e_unsupported_op, shtab_testops[i].sh_name);
}
}
/* NOTREACHED */
return(0);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/ksh93/tests/builtins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1002,13 +1002,13 @@ fi
actual=$($SHELL -c 'test foo =~ foo' 2>&1)
actual_status=$?
actual=${actual#*: }
expect='test: =~: operator not supported; use [[...]]'
expect='test: =~: operator not supported; use [[ ... ]]'
expect_status=2
[[ "$actual" = "$expect" ]] || err_exit "test =~ failed (expected $expect, got $actual)"
[[ "$actual_status" = "$expect_status" ]] ||
err_exit "test =~ failed with the wrong exit status (expected $expect_status, got $actual_status)"
# Invalid operators 'test' and '[[...]]' both reject should also cause an error with exit status 2.
# Invalid operators 'test' and '[[ ... ]]' both reject should also cause an error with exit status 2.
for operator in '===' ']]'
do
actual="$($SHELL -c "test foo $operator foo" 2>&1)"
Expand Down

0 comments on commit f8de1f1

Please sign in to comment.