remove some cppcheck warnings

This commit is contained in:
Philippe Teuwen 2019-06-12 06:41:23 -07:00
commit 1ebfa897c8
24 changed files with 145 additions and 146 deletions

View file

@ -341,26 +341,24 @@ gcd(int a, int b) {
static void
permute_args(int panonopt_start, int panonopt_end, int opt_end,
char *const *nargv) {
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
char *swap;
/*
* compute lengths of blocks and number and size of cycles
*/
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
ncycle = gcd(nnonopts, nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
int nnonopts = panonopt_end - panonopt_start;
int nopts = opt_end - panonopt_end;
int ncycle = gcd(nnonopts, nopts);
int cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
cstart = panonopt_end + i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
for (int i = 0; i < ncycle; i++) {
int cstart = panonopt_end + i;
int pos = cstart;
for (int j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
pos -= nnonopts;
else
pos += nopts;
swap = nargv[pos];
char *swap = nargv[pos];
/* LINTED const cast */
((char **) nargv)[pos] = nargv[cstart];
/* LINTED const cast */