lib: fix offset in tst_resm_hexd
PATCH 1/1 lib: fix offset in tst_resm_hexd
Commit f72ca5b9c484 "lib: add tst_res_hexd for newlib" broke tst_resm_hexd when I moved "offset = strlen(tmesg)" before macro that expands varargs.
Fix it by moving offset initialisation after EXPAND_VAR_ARGS.
--- lib/tst_res.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/tst_res.c +2 -1
@@ -509,7 +509,7 @@ void tst_resm_hexd_(const char *file, const int lineno, int ttype,char tmesg[USERMESG ];static const size_t symb_num =2 ;/* xx */ static const size_t size_max =16 ; -size_t offset =strlen (tmesg); +size_t offset;size_t i;char *pmesg = tmesg;tst_res_func_t res_func;
@@ -520,6 +520,7 @@ void tst_resm_hexd_(const char *file, const int lineno, int ttype, res_func = tst_res__;EXPAND_VAR_ARGS (tmesg, arg_fmt,USERMESG ); + offset =strlen (tmesg);if (size > size_max || size ==0 || (offset + size * (symb_num +1 )) >=USERMESG )
Signature · 1 line
1.8.3.1
PATCH 1/1 lib: fix offset in tst_resm_hexd
Hi!
Quoted 25 lines
Commit
f72ca5b9c484"lib: addtst_res_hexdfor newlib" broketst_resm_hexdwhen I moved "offset = strlen(tmesg)" before macro that expands varargs.Fix it by moving offset initialisation after
EXPAND_VAR_ARGS.Signed-off-by Jan Stancek <[email protected]>--- lib/tst_res.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/tst_res.c +1
-1@@ -509,7 +509,7 @@ void tst_resm_hexd_(const char *file, const int lineno, int ttype,char tmesg[USERMESG ];static const size_t symb_num =2 ;/* xx */ static const size_t size_max =16 ; -size_t offset =strlen (tmesg); +size_t offset;size_t i;char *pmesg = tmesg;tst_res_func_t res_func;
lib/tst_res.c void tst_resm_hexd_(const char *file, const int lineno, int ttype, · line 526
Quoted 7 lines
lib/tst_res.c +1
-0@@ -520,6 +520,7 @@ void tst_resm_hexd_(const char *file, const int lineno, int ttype, res_func = tst_res__;EXPAND_VAR_ARGS (tmesg, arg_fmt,USERMESG ); + offset =strlen (tmesg);if (size > size_max || size ==0 || (offset + size * (symb_num +1 )) >=USERMESG )
Good catch. Thanks for fixing this, acked.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 lib: fix offset in tst_resm_hexd
----- Original Message -----
Quoted 36 lines
From: "Cyril Hrubis" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Monday, 16 January, 2017 10:26:59 AM
Subject: Re: [PATCH] lib: fix offset intst_resm_hexdHi!
Quoted 29 lines
Commit
f72ca5b9c484"lib: addtst_res_hexdfor newlib" broketst_resm_hexdwhen I moved "offset = strlen(tmesg)" before macro that expands varargs.Fix it by moving offset initialisation after
EXPAND_VAR_ARGS.Signed-off-by Jan Stancek <[email protected]>--- lib/tst_res.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/tst_res.c +1
-1@@ -509,7 +509,7 @@ void tst_resm_hexd_(const char *file, const int lineno,int ttype, char tmesg[USERMESG];static const size_t symb_num =2 ;/* xx */ static const size_t size_max =16 ; -size_t offset =strlen (tmesg); +size_t offset;size_t i;char *pmesg = tmesg;lib/tst_res.c +0
-0tst_res_func_t res_func;@@ -520,6 +520,7 @@ void tst_resm_hexd_(const char *file, const int lineno,int ttype, res_func = tst_res__;
Quoted 7 lines
Quoted 5 lines
lib/tst_res.c +1
-0EXPAND_VAR_ARGS (tmesg, arg_fmt,USERMESG ); + offset =strlen (tmesg); if (size > size_max || size == 0 ||(offset + size * (
symb_num+ 1)) >= USERMESG)Good catch. Thanks for fixing this, acked.
Pushed.
Quoted 5 lines
--
Cyril Hrubis
[email protected]