* [PATCH] libc: fix __time_load_locale return code
@ 2023-05-11 6:32 Alexey Lapshin
2023-05-15 16:30 ` [PATCH v2] " Alexey Lapshin
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Lapshin @ 2023-05-11 6:32 UTC (permalink / raw)
To: newlib; +Cc: Alexey Gerenkov, Ivan Grokhotkov
newlib:
* libc/locale/timelocal.c: ret variable could have garbage
because
not initialized. explicit check for __HAVE_LOCALE_INFO__
---
newlib/libc/locale/timelocal.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/newlib/libc/locale/timelocal.c
b/newlib/libc/locale/timelocal.c
index 4b361544a..04ae1142f 100644
--- a/newlib/libc/locale/timelocal.c
+++ b/newlib/libc/locale/timelocal.c
@@ -147,10 +147,11 @@ int
__time_load_locale (struct __locale_t *locale, const char *name,
void *f_wctomb, const char *charset)
{
- int ret;
+ int ret = 0;
struct lc_time_T ti;
char *bufp = NULL;
+#ifdef __HAVE_LOCALE_INFO__
#ifdef __CYGWIN__
extern int __set_lc_time_from_win (const char *, const struct
lc_time_T *,
struct lc_time_T *, char **, void
*,
@@ -186,5 +187,6 @@ __time_load_locale (struct __locale_t *locale,
const char *name,
#else
/* TODO */
#endif
+#endif /*__HAVE_LOCALE_INFO__*/
return (ret);
}
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] libc: fix __time_load_locale return code
2023-05-11 6:32 [PATCH] libc: fix __time_load_locale return code Alexey Lapshin
@ 2023-05-15 16:30 ` Alexey Lapshin
2023-05-17 19:37 ` Jeff Johnston
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Lapshin @ 2023-05-15 16:30 UTC (permalink / raw)
To: newlib; +Cc: Alexey Gerenkov, Ivan Grokhotkov
newlib:
* libc/locale/timelocal.c: fix ret variable initialization.
Explicit __HAVE_LOCALE_INFO__ check
---
newlib/libc/locale/timelocal.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/newlib/libc/locale/timelocal.c b/newlib/libc/locale/timelocal.c
index 4b361544a..04ae1142f 100644
--- a/newlib/libc/locale/timelocal.c
+++ b/newlib/libc/locale/timelocal.c
@@ -147,10 +147,11 @@ int
__time_load_locale (struct __locale_t *locale, const char *name,
void *f_wctomb, const char *charset)
{
- int ret;
+ int ret = 0;
struct lc_time_T ti;
char *bufp = NULL;
+#ifdef __HAVE_LOCALE_INFO__
#ifdef __CYGWIN__
extern int __set_lc_time_from_win (const char *, const struct lc_time_T *,
struct lc_time_T *, char **, void *,
@@ -186,5 +187,6 @@ __time_load_locale (struct __locale_t *locale, const char *name,
#else
/* TODO */
#endif
+#endif /*__HAVE_LOCALE_INFO__*/
return (ret);
}
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] libc: fix __time_load_locale return code
2023-05-15 16:30 ` [PATCH v2] " Alexey Lapshin
@ 2023-05-17 19:37 ` Jeff Johnston
2023-05-17 21:49 ` Jeff Johnston
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Johnston @ 2023-05-17 19:37 UTC (permalink / raw)
To: Alexey Lapshin; +Cc: newlib, Alexey Gerenkov, Ivan Grokhotkov
[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]
Hi Alexey,
I see the point for adding the ret=0 but the additional flag check isn't
needed because the function is meant to only be called by __loadlocale()
which doesn't make the call unless __HAVE_LOCALE_INFO__ is set. If you
want, I can make the change or else you can resubmit the patch.
-- Jeff J.
On Mon, May 15, 2023 at 12:30 PM Alexey Lapshin <
alexey.lapshin@espressif.com> wrote:
> newlib:
> * libc/locale/timelocal.c: fix ret variable initialization.
> Explicit __HAVE_LOCALE_INFO__ check
> ---
> newlib/libc/locale/timelocal.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/newlib/libc/locale/timelocal.c
> b/newlib/libc/locale/timelocal.c
> index 4b361544a..04ae1142f 100644
> --- a/newlib/libc/locale/timelocal.c
> +++ b/newlib/libc/locale/timelocal.c
> @@ -147,10 +147,11 @@ int
> __time_load_locale (struct __locale_t *locale, const char *name,
> void *f_wctomb, const char *charset)
> {
> - int ret;
> + int ret = 0;
> struct lc_time_T ti;
> char *bufp = NULL;
>
> +#ifdef __HAVE_LOCALE_INFO__
> #ifdef __CYGWIN__
> extern int __set_lc_time_from_win (const char *, const struct lc_time_T
> *,
> struct lc_time_T *, char **, void *,
> @@ -186,5 +187,6 @@ __time_load_locale (struct __locale_t *locale, const
> char *name,
> #else
> /* TODO */
> #endif
> +#endif /*__HAVE_LOCALE_INFO__*/
> return (ret);
> }
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] libc: fix __time_load_locale return code
2023-05-17 19:37 ` Jeff Johnston
@ 2023-05-17 21:49 ` Jeff Johnston
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Johnston @ 2023-05-17 21:49 UTC (permalink / raw)
To: Alexey Lapshin; +Cc: newlib, Alexey Gerenkov, Ivan Grokhotkov
[-- Attachment #1: Type: text/plain, Size: 1786 bytes --]
Hi Alexey,
After thinking about it, the macro check is fine. I have checked in the
patch.
Thanks,
-- Jeff J.
On Wed, May 17, 2023 at 3:37 PM Jeff Johnston <jjohnstn@redhat.com> wrote:
> Hi Alexey,
>
> I see the point for adding the ret=0 but the additional flag check isn't
> needed because the function is meant to only be called by __loadlocale()
> which doesn't make the call unless __HAVE_LOCALE_INFO__ is set. If you
> want, I can make the change or else you can resubmit the patch.
>
> -- Jeff J.
>
> On Mon, May 15, 2023 at 12:30 PM Alexey Lapshin <
> alexey.lapshin@espressif.com> wrote:
>
>> newlib:
>> * libc/locale/timelocal.c: fix ret variable initialization.
>> Explicit __HAVE_LOCALE_INFO__ check
>> ---
>> newlib/libc/locale/timelocal.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/newlib/libc/locale/timelocal.c
>> b/newlib/libc/locale/timelocal.c
>> index 4b361544a..04ae1142f 100644
>> --- a/newlib/libc/locale/timelocal.c
>> +++ b/newlib/libc/locale/timelocal.c
>> @@ -147,10 +147,11 @@ int
>> __time_load_locale (struct __locale_t *locale, const char *name,
>> void *f_wctomb, const char *charset)
>> {
>> - int ret;
>> + int ret = 0;
>> struct lc_time_T ti;
>> char *bufp = NULL;
>>
>> +#ifdef __HAVE_LOCALE_INFO__
>> #ifdef __CYGWIN__
>> extern int __set_lc_time_from_win (const char *, const struct
>> lc_time_T *,
>> struct lc_time_T *, char **, void *,
>> @@ -186,5 +187,6 @@ __time_load_locale (struct __locale_t *locale, const
>> char *name,
>> #else
>> /* TODO */
>> #endif
>> +#endif /*__HAVE_LOCALE_INFO__*/
>> return (ret);
>> }
>> --
>> 2.34.1
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-17 21:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11 6:32 [PATCH] libc: fix __time_load_locale return code Alexey Lapshin
2023-05-15 16:30 ` [PATCH v2] " Alexey Lapshin
2023-05-17 19:37 ` Jeff Johnston
2023-05-17 21:49 ` Jeff Johnston
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).