Re: [PATCH v3 3/4] tools/nolibc: implement fd-based FILE streams

From: Mark Brown
Date: Thu Apr 13 2023 - 10:20:25 EST


On Thu, Apr 13, 2023 at 03:09:27PM +0200, linux@xxxxxxxxxxxxxx wrote:
> Apr 12, 2023 17:58:45 Mark Brown <broonie@xxxxxxxxxx>:

> > Nothing in this change (or anything else in the series AFAICT) causes
> > STDx_FILENO to be declared so we get errors like below in -next when a
> > kselftest is built with this version of nolibc:

> These definitions come from
> "tools/nolibc: add definitions for standard fds".
> This patch was part of the nolibc stack protector series which is older than this series and went through the same channels.
> So I'm not sure how one series made it into next and the other didn't.

> This would also have been noticed by Willy and Paul running their tests.

Hrm, that commit is actually in -next and Paul's pull request, not sure
why it wasn't showing up in greps. The issue is that you've added a
dependency from nolibc's stdio.h to unistd.h but nolibc.h includes
unistd.h last and there's no other include, meaning that at the time
that stdio.h is compiled there's no definition of the constants visible.

The below fixes the issue, I'll submit it properly later today:

diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 04739a6293c4..05a228a6ee78 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -99,11 +99,11 @@
#include "sys.h"
#include "ctype.h"
#include "signal.h"
+#include "unistd.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "time.h"
-#include "unistd.h"
#include "stackprotector.h"

/* Used by programs to avoid std includes */

Attachment: signature.asc
Description: PGP signature