Skip to content

Commit

Permalink
cppcheck : Condition is always true :
Browse files Browse the repository at this point in the history
	dhcp.c : i : int dhcp_rebind(pcs *pc)
	dhcp.c : ok : int dhcp_rebind(pcs *pc)
	packets6.c : j : u_char *nbDiscovery(pcs *pc, ip6 *dst)
	readline : start : int findhistory(struct rls *rls, int start)
  • Loading branch information
Raizo62 committed Jul 30, 2023
1 parent 3dfc375 commit bc46e66
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
16 changes: 7 additions & 9 deletions src/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ int dhcp_rebind(pcs *pc)
/* request */
i = 0;
ok = 0;
while (i < 3 && !ok) {
while (!ok) {
m = dhcp4_request(pc);
if (m == NULL) {
sleep(1);
Expand All @@ -739,14 +739,12 @@ int dhcp_rebind(pcs *pc)
free(p);
}
}
if (ok) {
if (pc->ip4.dhcp.renew == 0)
pc->ip4.dhcp.renew = pc->ip4.dhcp.lease / 2;
if (pc->ip4.dhcp.rebind == 0)
pc->ip4.dhcp.rebind = pc->ip4.dhcp.lease * 7 / 8;
return 1;
}
return 0;

if (pc->ip4.dhcp.renew == 0)
pc->ip4.dhcp.renew = pc->ip4.dhcp.lease / 2;
if (pc->ip4.dhcp.rebind == 0)
pc->ip4.dhcp.rebind = pc->ip4.dhcp.lease * 7 / 8;
return 1;
}

int dhcp_enq(pcs *pc, const struct packet *m)
Expand Down
5 changes: 2 additions & 3 deletions src/packets6.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ struct packet *udp6Reply(struct packet *m0)
*/
u_char *nbDiscovery(pcs *pc, ip6 *dst)
{
int i, j;
int i;
static u_char mac[ETH_ALEN] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
int waittime = 1000;
struct timeval tv;
Expand Down Expand Up @@ -777,8 +777,7 @@ u_char *nbDiscovery(pcs *pc, ip6 *dst)

/* find neighbor */
i = 0;
j = -1;
while ((i++ < 3) && (j == -1)){
while ( i++ < 3 ){
struct packet *m;

m = nb_sol(pc, dst);
Expand Down
8 changes: 4 additions & 4 deletions src/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ int findhistory(struct rls *rls, int start)
if (start >= 0) {
start++;
return (start < rls->hist_total) ? start : -1;
} else {
start = 0 - start;
start --;
return (start > - 1) ? start : -1;
} else { // [-1 , -inf [
start = 0 - start; // [1 , inf [
start --; // [0 , inf [
return start;
}
} else {
if (start >= 0) {
Expand Down

0 comments on commit bc46e66

Please sign in to comment.