[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cex: avoid uninitialized variables
From: |
Akim Demaille |
Subject: |
cex: avoid uninitialized variables |
Date: |
Sat, 16 May 2020 10:51:53 +0200 |
> Le 13 mai 2020 à 19:58, Akim Demaille <address@hidden> a écrit :
>
> commit 0d72c68954d5575d2aa6d26b440558b53f901918
> Author: Akim Demaille <address@hidden>
> Date: Wed May 13 18:38:09 2020 +0200
>
> cex: fixes
>
> * src/conflicts.c, src/counterexample.c, src/derivation.c:
> Do not output diagnostics on stdout, that's the job of stderr, and the
> testsuite heavily depend on this.
> Do not leave trailing spaces in the output.
> * tests/counterexample.at: Use AT_KEYWORDS.
> Specify the expected outputs.
> * tests/local.mk: Add counterexample.at.
I have extracted the following commit from that one, to make it smaller.
commit 19e9c1d0a4ab8e3e4abd9a89dd47d4f66a117788
Author: Akim Demaille <address@hidden>
Date: Sat May 16 10:46:17 2020 +0200
cex: avoid uninitialized variables
* src/conflicts.c (find_state_item_number): New.
Use it to avoid uninitialized variables.
diff --git a/src/conflicts.c b/src/conflicts.c
index 3cf21c47..b6cccd76 100644
--- a/src/conflicts.c
+++ b/src/conflicts.c
@@ -625,6 +625,15 @@ conflicts_total_count (void)
return count_sr_conflicts () + count_rr_conflicts ();
}
+static state_item_number
+find_state_item_number (const rule *r, state_number sn)
+{
+ for (int i = state_item_map[sn]; i < state_item_map[sn + 1]; ++i)
+ if (item_number_as_rule_number (*state_items[i].item) == r->number)
+ return i;
+ abort ();
+}
+
static void
report_state_counterexamples (const state *s)
{
@@ -633,19 +642,8 @@ report_state_counterexamples (const state *s)
for (int i = 0; i < reds->num; ++i)
{
rule *r1 = reds->rules[i];
- state_item_number c1;
- for (int j = state_item_map[sn];
- j < state_item_map[sn + 1]; ++j)
- {
- if (item_number_as_rule_number (*state_items[j].item) == r1->number)
- {
- c1 = j;
- break;
- }
- }
-
- for (int j = state_item_map[sn];
- j < state_item_map[sn + 1]; ++j)
+ const state_item_number c1 = find_state_item_number (r1, sn);
+ for (int j = state_item_map[sn]; j < state_item_map[sn + 1]; ++j)
{
if (SI_DISABLED (j))
continue;
- Re: [PATCH 0/5] Conflict Counterexample Generation, (continued)
- Re: [PATCH 0/5] Conflict Counterexample Generation, Akim Demaille, 2020/05/13
- Re: [PATCH 0/5] Conflict Counterexample Generation, Vincent Imbimbo, 2020/05/13
- Re: [PATCH 0/5] Conflict Counterexample Generation, Akim Demaille, 2020/05/13
- Re: [PATCH 0/5] Conflict Counterexample Generation, Akim Demaille, 2020/05/13
- Re: [PATCH 0/5] Conflict Counterexample Generation, Akim Demaille, 2020/05/14
- Re: [PATCH 0/5] Conflict Counterexample Generation, Akim Demaille, 2020/05/16
- cex: isolate missing API from gl_list, Akim Demaille, 2020/05/16
- cex: stylistic changes, Akim Demaille, 2020/05/16
- cex: fix a crash, Akim Demaille, 2020/05/16
- cex: style changes in state-item, Akim Demaille, 2020/05/16
- cex: avoid uninitialized variables,
Akim Demaille <=