abg-ir: add missing else

Message ID 20221016042642.37944-1-hexiaole1994@126.com
State New
Headers
Series abg-ir: add missing else |

Commit Message

Xiaole He Oct. 16, 2022, 4:26 a.m. UTC
  From: Xiaole He <hexiaole@kylinos.cn>

In 'bind_function_type_life_time' function of 'src/abg-ir.cc', the code
obtains the member 'const environment*' of 'class function_type', that
is, the 'e' variable in below code. And assure the obtained
'environment*' is same as the 'const environment*' of the
'class translation_unit', that is, the'env' variable in below code:

/* src/abg-ir.cc begin */
1  void
2  translation_unit::bind_function_type_life_time(function_type_sptr ftype)
3  {
4    ...
5    const environment* env = get_environment();
6    ...
7    if (const environment* e = ftype->get_environment())
8      ABG_ASSERT(env == e);
9    ftype->set_environment(const_cast<environment*>(env));
10
11   if (const translation_unit* existing_tu = ftype->get_translation_unit())
12     ABG_ASSERT(existing_tu == this);
13   else
14     ftype->set_translation_unit(const_cast<translation_unit*>(this));
15    ...
/* src/abg-ir.cc end */

There was a missing 'else' between the 'line 8' and line 9', as the
explicit 'else' at the 'line 13'. Without the 'else' between the
'line 8' and line 9', there will be a redundant assignment at 'line 9'
under the condition when the 'env' is equal to 'e'.
This patch add the missing 'else' between the 'line 8' and 'line 9'.

        * src/abg-ir.cc (bind_function_type_life_time): add missing
        else

Signed-off-by: Xiaole He <hexiaole@kylinos.cn>
Tested-by: Xiaole He <hexiaole@kylinos.cn>
---
 src/abg-ir.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Dodji Seketeli Oct. 17, 2022, 2:13 p.m. UTC | #1
Hello Xiaole,

Xiaole He via Libabigail <libabigail@sourceware.org> a écrit:

> From: Xiaole He <hexiaole@kylinos.cn>
>
> In 'bind_function_type_life_time' function of 'src/abg-ir.cc', the code
> obtains the member 'const environment*' of 'class function_type', that
> is, the 'e' variable in below code. And assure the obtained
> 'environment*' is same as the 'const environment*' of the
> 'class translation_unit', that is, the'env' variable in below code:
>
> /* src/abg-ir.cc begin */
> 1  void
> 2  translation_unit::bind_function_type_life_time(function_type_sptr ftype)
> 3  {
> 4    ...
> 5    const environment* env = get_environment();
> 6    ...
> 7    if (const environment* e = ftype->get_environment())
> 8      ABG_ASSERT(env == e);
> 9    ftype->set_environment(const_cast<environment*>(env));
> 10
> 11   if (const translation_unit* existing_tu = ftype->get_translation_unit())
> 12     ABG_ASSERT(existing_tu == this);
> 13   else
> 14     ftype->set_translation_unit(const_cast<translation_unit*>(this));
> 15    ...
> /* src/abg-ir.cc end */
>
> There was a missing 'else' between the 'line 8' and line 9', as the
> explicit 'else' at the 'line 13'. Without the 'else' between the
> 'line 8' and line 9', there will be a redundant assignment at 'line 9'
> under the condition when the 'env' is equal to 'e'.
> This patch add the missing 'else' between the 'line 8' and 'line 9'.
>
>         * src/abg-ir.cc (bind_function_type_life_time): add missing
>         else
>
> Signed-off-by: Xiaole He <hexiaole@kylinos.cn>
> Tested-by: Xiaole He <hexiaole@kylinos.cn>

Applied to the master branch.  Thanks!

[...]

Cheers,
  
Xiaole He Oct. 18, 2022, 3:24 a.m. UTC | #2
Thank you for reviewing.

















At 2022-10-17 22:13:45, "Dodji Seketeli" <dodji@seketeli.org> wrote:
>Hello Xiaole,
>
>Xiaole He via Libabigail <libabigail@sourceware.org> a écrit:
>
>> From: Xiaole He <hexiaole@kylinos.cn>
>>
>> In 'bind_function_type_life_time' function of 'src/abg-ir.cc', the code
>> obtains the member 'const environment*' of 'class function_type', that
>> is, the 'e' variable in below code. And assure the obtained
>> 'environment*' is same as the 'const environment*' of the
>> 'class translation_unit', that is, the'env' variable in below code:
>>
>> /* src/abg-ir.cc begin */
>> 1  void
>> 2  translation_unit::bind_function_type_life_time(function_type_sptr ftype)
>> 3  {
>> 4    ...
>> 5    const environment* env = get_environment();
>> 6    ...
>> 7    if (const environment* e = ftype->get_environment())
>> 8      ABG_ASSERT(env == e);
>> 9    ftype->set_environment(const_cast<environment*>(env));
>> 10
>> 11   if (const translation_unit* existing_tu = ftype->get_translation_unit())
>> 12     ABG_ASSERT(existing_tu == this);
>> 13   else
>> 14     ftype->set_translation_unit(const_cast<translation_unit*>(this));
>> 15    ...
>> /* src/abg-ir.cc end */
>>
>> There was a missing 'else' between the 'line 8' and line 9', as the
>> explicit 'else' at the 'line 13'. Without the 'else' between the
>> 'line 8' and line 9', there will be a redundant assignment at 'line 9'
>> under the condition when the 'env' is equal to 'e'.
>> This patch add the missing 'else' between the 'line 8' and 'line 9'.
>>
>>         * src/abg-ir.cc (bind_function_type_life_time): add missing
>>         else
>>
>> Signed-off-by: Xiaole He <hexiaole@kylinos.cn>
>> Tested-by: Xiaole He <hexiaole@kylinos.cn>
>
>Applied to the master branch.  Thanks!
>
>[...]
>
>Cheers,
>
>-- 
>		Dodji
  

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 51d1d550..b53df0cd 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -1509,7 +1509,8 @@  translation_unit::bind_function_type_life_time(function_type_sptr ftype) const
   // translation unit.
   if (const environment* e = ftype->get_environment())
     ABG_ASSERT(env == e);
-  ftype->set_environment(const_cast<environment*>(env));
+  else
+    ftype->set_environment(const_cast<environment*>(env));
 
   if (const translation_unit* existing_tu = ftype->get_translation_unit())
     ABG_ASSERT(existing_tu == this);