Unconditionally call __gconv_get_path when reading iconv configuration

Message ID 20181101160235.GA90664@aloka.lostca.se
State New
Headers show
Series
  • Unconditionally call __gconv_get_path when reading iconv configuration
Related show

Commit Message

Arjun Shankar Nov. 1, 2018, 4:02 p.m.
__gconv_read_conf is only ever called once during the program's lifetime.
This means that __gconv_path_elem is always uninitialized when the function
begins executing.  __gconv_get_path has an assert to ensure that this
expected runtime behaviour is always exhibited.  Given this, checking for a
NULL value before calling __gconv_get_path is unnecessary.  This commit
drops the condition and calls __gconv_get_path unconditionally.

ChangeLog:

2018-11-01  Arjun Shankar  <arjun@redhat.com>

	* iconv/gconv_conf.c (__gconv_read_conf): Remove NULL check for
	__gconv_path_elem and call __gconv_get_path unconditionally.

Tested on x86_64.
---

-- 
2.17.2

Comments

Florian Weimer Nov. 5, 2018, 11:46 a.m. | #1
* Arjun Shankar:

> __gconv_read_conf is only ever called once during the program's lifetime.

> This means that __gconv_path_elem is always uninitialized when the function

> begins executing.  __gconv_get_path has an assert to ensure that this

> expected runtime behaviour is always exhibited.  Given this, checking for a

> NULL value before calling __gconv_get_path is unnecessary.  This commit

> drops the condition and calls __gconv_get_path unconditionally.

>

> ChangeLog:

>

> 2018-11-01  Arjun Shankar  <arjun@redhat.com>

>

> 	* iconv/gconv_conf.c (__gconv_read_conf): Remove NULL check for

> 	__gconv_path_elem and call __gconv_get_path unconditionally.


This is okay.

Thanks,
Florian

Patch

diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 78010491e6..2b73dd8f45 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -552,8 +552,7 @@  __gconv_read_conf (void)
 
 #ifndef STATIC_GCONV
   /* Find out where we have to look.  */
-  if (__gconv_path_elem == NULL)
-    __gconv_get_path ();
+  __gconv_get_path ();
 
   for (cnt = 0; __gconv_path_elem[cnt].name != NULL; ++cnt)
     {