diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-02-14 15:11:13 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-03-08 01:19:14 +0100 |
| commit | f94f4a89ff6f31384cdfe77b5084601e7de2a131 (patch) | |
| tree | 724c674f4e79bedc5888dde4e1fa4d09fc81d221 /simplify.c | |
| parent | c50f5272ea4275b3f79d2c71115f2be014ed11ee (diff) | |
| download | sparse-dev-f94f4a89ff6f31384cdfe77b5084601e7de2a131.tar.gz | |
ptrlist: change return value of linearize_ptr_list()/ptr_list_to_array()
The function linearize_ptr_list() is annoying to use because it
returns the number of elements put in the array. So, if you need
to know if the list contained the expected number of entries,
you need to allocate an array with one extra entry and check
that the return value is one less than this size.
So, change the function to return the total number of entries
in the list. In other words, the return value corresponds now to
the number of entries that could be copied if the size would be
unlimited, much like it's done for snprintf().
The number of entries effectively copied stays, of course,
limited by the size specified for the array.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'simplify.c')
| -rw-r--r-- | simplify.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -108,7 +108,7 @@ static int get_phisources(struct instruction *sources[], int nbr, struct instruc static int if_convert_phi(struct instruction *insn) { struct instruction *array[2]; - struct basic_block *parents[3]; + struct basic_block *parents[2]; struct basic_block *bb, *bb1, *bb2, *source; struct instruction *br; pseudo_t p1, p2; @@ -116,7 +116,7 @@ static int if_convert_phi(struct instruction *insn) bb = insn->bb; if (get_phisources(array, 2, insn)) return 0; - if (ptr_list_to_array(bb->parents, parents, 3) != 2) + if (ptr_list_to_array(bb->parents, parents, 2) != 2) return 0; p1 = array[0]->phi_src; bb1 = array[0]->bb; |
