<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Sep 4, 2021 at 5:48 AM Petr Vorel <<a href="mailto:petr.vorel@gmail.com" target="_blank">petr.vorel@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">which was previously used for non-linux OS (not relevant to LTP thus not<br>
used in LTP), for linux stderr directly was used.<br>
<br>
This fixes compilation on MUSL which does not like assignment to stderr:<br>
<br>
process.c:553:14: error: assignment of read-only variable 'stderr'<br>
  553 |      debugfp = fopen(foo, "a+");<br>
      |              ^<br>
<br>
NOTE: needed to initialization in main(), because C standard does not<br>
require stdin, stdout and stderr to be constants (at least not C99),<br>
otherwise it fails to compile:<br>
<br>
process.c:144:15: error: initializer element is not constant<br>
<br>
Signed-off-by: Petr Vorel <<a href="mailto:petr.vorel@gmail.com" target="_blank">petr.vorel@gmail.com</a>><br>
---<br>
Hi,<br>
<br>
not really sure why anything needs to be assigned to stderr and whether<br>
this is a correct approach. Comments are welcome.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Hmm, I guess that the original purpose is to redirect stderr to</div><div class="gmail_default" style="font-size:small">another destination. But it made a mistake which assigns new</div><div class="gmail_default" style="font-size:small">FILE stream to stderr, AFAIK, we should not do like that.</div><div class="gmail_default" style="font-size:small">A recomened way is:</div><div class="gmail_default" style="font-size:small">    FILE *<span class="gmail_default">debugfp</span> = freopen(<span class="gmail_default">foo</span>, "w", stderr );<br></div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Or, it just wants to make compatible but forget that definition in use then.</div><div><br></div><div><br></div><div><div class="gmail_default" style="font-size:small">Anyway, your fix looks good.</div><div class="gmail_default" style="font-size:small"></div><div class="gmail_default" style="font-size:small">Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>></div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Kind regards,<br>
Petr<br>
<br>
 testcases/kernel/sched/process_stress/process.c | 12 +++++-------<br>
 1 file changed, 5 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/testcases/kernel/sched/process_stress/process.c b/testcases/kernel/sched/process_stress/process.c<br>
index a5ff80987..11837c3cb 100644<br>
--- a/testcases/kernel/sched/process_stress/process.c<br>
+++ b/testcases/kernel/sched/process_stress/process.c<br>
@@ -141,13 +141,8 @@ timer_t timer;                     /* timer structure */<br>
<br>
 Pinfo *shmaddr;                        /* Start address  of shared memory */<br>
<br>
-#ifndef _LINUX<br>
-FILE *errfp = stderr;          /* error file pointer, probably not necessary */<br>
-FILE *debugfp = stderr;                /* debug file pointer, used if AUSDEBUG set */<br>
-#else<br>
-#define errfp stderr<br>
-#define debugfp stderr<br>
-#endif<br>
+FILE *errfp;<br>
+FILE *debugfp;<br>
<br>
 struct envstruct *edat = envdata;      /* pointer to environment data */<br>
<br>
@@ -1221,6 +1216,9 @@ void doit(void)<br>
 /* main */<br>
 int main(int argc, char *argv[])<br>
 {<br>
+       errfp = stderr;<br>
+       debugfp = stderr;<br>
+<br>
        extern Pinfo *shmaddr;  /* start address of shared memory */<br>
<br>
        prtln();<br>
-- <br>
2.33.0<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>