Skip to contentSkip to conversation

tty: vt: conmakehash: remove non-portable code printing comment header

PATCH In review Masahiro Yamada 2 participants 4 messages Aug 9, 2024 – Aug 12, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: vt: conmakehash: remove non-portable code printing comment header

Commit 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env") included <linux/limits.h>, which invoked another (wrong) patch that tried to address a build error on macOS.

According to the specification [1], the correct header to use PATH_MAX is <limits.h>.

The minimal fix would be to replace <linux/limits.h> with <limits.h>.

However, the following commits seem questionable to me:

- 3bd85c6c97b2 ("tty: vt: conmakehash: Don't mention the full path of the input in output")
- 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env")

These commits made too many efforts to cope with a comment header in drivers/tty/vt/consolemap_deftbl.c:

/*
* Do not edit this file; it was automatically generated by *
* conmakehash drivers/tty/vt/cp437.uni > [this file] *
*/

With this commit, the header part of the generate C file will be simplified as follows:

/*
* Automatically generated file; Do not edit.
*/

BTW, another series of excessive efforts for a comment header can be seen in the following:

- 5ef6dc08cfde ("lib/build_OID_registry: don't mention the full path of the script in output")
- 2fe29fe94563 ("lib/build_OID_registry: avoid non-destructive substitution for Perl < 5.13.2 compat")

[1]: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html

Fixes 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env")

---

 drivers/tty/vt/conmakehash.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/tty/vt/conmakehash.c +2 -10
index 82d9db68b2ce..a931fcde7ad9 100644
@@ -11,8 +11,6 @@
  * Copyright (C) 1995-1997 H. Peter Anvin
  */
 
-#include <libgen.h>
-#include <linux/limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sysexits.h>
@@ -79,7 +77,6 @@ int main(int argc, char *argv[])
 {
   FILE *ctbl;
   const char *tblname;
-  char base_tblname[PATH_MAX];
   char buffer[65536];
   int fontlen;
   int i, nuni, nent;
@@ -245,20 +242,15 @@ int main(int argc, char *argv[])
   for ( i = 0 ; i < fontlen ; i++ )
     nuni += unicount[i];
 
-  strncpy(base_tblname, tblname, PATH_MAX);
-  base_tblname[PATH_MAX - 1] = 0;
   printf("\
 /*\n\
- * Do not edit this file; it was automatically generated by\n\
- *\n\
- * conmakehash %s > [this file]\n\
- *\n\
+ * Automatically generated file; Do not edit.\n\
  */\n\
 \n\
 #include <linux/types.h>\n\
 \n\
 u8 dfont_unicount[%d] = \n\
-{\n\t", basename(base_tblname), fontlen);
+{\n\t", fontlen);
 
   for ( i = 0 ; i < fontlen ; i++ )
     {
Signature · 1 line
2.43.0
#1 lore raw
Quoted 8 lines · Masahiro Yamada

Commit 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env") included <linux/limits.h>, which invoked another (wrong) patch that tried to address a build error on macOS.

According to the specification [1], the correct header to use PATH_MAX is <limits.h>.

The minimal fix would be to replace <linux/limits.h> with <limits.h>.

I can change that in a v2.

Quoted 9 lines

However, the following commits seem questionable to me:

- 3bd85c6c97b2 ("tty: vt: conmakehash: Don't mention the full path of the input in output")
- 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env")

These commits made too many efforts to cope with a comment header in drivers/tty/vt/consolemap_deftbl.c:

Quoted 6 lines

/*
* Do not edit this file; it was automatically generated by *
* conmakehash drivers/tty/vt/cp437.uni > [this file] *
*/

This is the output you get when keeping the build artifacts within the linux source tree.
However if you keep the artifacts outside the source tree (make O=/somepath ...) the output looks like this:

    /*
     * Do not edit this file; it was automatically generated by
     *
     * conmakehash /path-to-kernel-source-tree/drivers/tty/vt/cp437.uni > [this file]
     *
     */

i.e. it does keep a reference to where in your filesystem the kernel source did reside when building which is against the goal of having a reproducable build.

Quoted 7 lines

With this commit, the header part of the generate C file will be simplified as follows:

/*
* Automatically generated file; Do not edit.
*/

This is not what I observed, for me with this proposed commit the comment becomes with or without the 'O=somepath':

    /*
     * Do not edit this file; it was automatically generated by
     *
     * conmakehash cp437.uni > [this file]
     *
     */

i.e. it strips the directory path of the chartable source file used.

Regards
Max

Quoted 65 lines

BTW, another series of excessive efforts for a comment header can be seen in the following:

- 5ef6dc08cfde ("lib/build_OID_registry: don't mention the full path of the script in output")
- 2fe29fe94563 ("lib/build_OID_registry: avoid non-destructive substitution for Perl < 5.13.2 compat")

[1]: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html

Fixes 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env")

---

 drivers/tty/vt/conmakehash.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/tty/vt/conmakehash.c +2 -10
index 82d9db68b2ce..a931fcde7ad9 100644
@@ -11,8 +11,6 @@
  * Copyright (C) 1995-1997 H. Peter Anvin
  */
 
-#include <libgen.h>
-#include <linux/limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sysexits.h>
@@ -79,7 +77,6 @@ int main(int argc, char *argv[])
 {
   FILE *ctbl;
   const char *tblname;
-  char base_tblname[PATH_MAX];
   char buffer[65536];
   int fontlen;
   int i, nuni, nent;
@@ -245,20 +242,15 @@ int main(int argc, char *argv[])
   for ( i = 0 ; i < fontlen ; i++ )
     nuni += unicount[i];
 
-  strncpy(base_tblname, tblname, PATH_MAX);
-  base_tblname[PATH_MAX - 1] = 0;
   printf("\
 /*\n\
- * Do not edit this file; it was automatically generated by\n\
- *\n\
- * conmakehash %s > [this file]\n\
- *\n\
+ * Automatically generated file; Do not edit.\n\
  */\n\
 \n\
 #include <linux/types.h>\n\
 \n\
 u8 dfont_unicount[%d] = \n\
-{\n\t", basename(base_tblname), fontlen);
+{\n\t", fontlen);
 
   for ( i = 0 ; i < fontlen ; i++ )
     {
Signature · 1 line
2.43.0
#2 lore raw
Quoted 11 lines · Max Krummenacher
Quoted 8 lines · Masahiro Yamada

Commit 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env") included <linux/limits.h>, which invoked another (wrong) patch that tried to address a build error on macOS.

According to the specification [1], the correct header to use PATH_MAX is <limits.h>.

The minimal fix would be to replace <linux/limits.h> with <limits.h>.

I can change that in a v2.

You cannot.

Your buggy commit already landed in Linus' tree:

https://github.com/torvalds/linux/commit/6e20753da6bc651e02378a0cdb78f16c42098c88

Quoted 28 lines
Quoted 9 lines

However, the following commits seem questionable to me:

- 3bd85c6c97b2 ("tty: vt: conmakehash: Don't mention the full path of the input in output")
- 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env")

These commits made too many efforts to cope with a comment header in drivers/tty/vt/consolemap_deftbl.c:

Quoted 6 lines

/*
* Do not edit this file; it was automatically generated by *
* conmakehash drivers/tty/vt/cp437.uni > [this file] *
*/

This is the output you get when keeping the build artifacts within the linux source tree.
However if you keep the artifacts outside the source tree (make O=/somepath ...) the output looks like this:

    /*
     * Do not edit this file; it was automatically generated by
     *
     * conmakehash /path-to-kernel-source-tree/drivers/tty/vt/cp437.uni > [this file]
     *
     */
Quoted 3 lines

i.e. it does keep a reference to where in your filesystem the kernel source did reside when building which is against the goal of having a reproducable build.

You do not need to educate me.

It is well described in commit 3bd85c6c97b2d232638594bf828de62083fe3389 and I know how it works.

Quoted 11 lines
Quoted 7 lines

With this commit, the header part of the generate C file will be simplified as follows:

/*
* Automatically generated file; Do not edit.
*/

This is not what I observed, for me with this proposed commit the comment becomes with or without the 'O=somepath':

Quoted 8 lines
    /*
     * Do not edit this file; it was automatically generated by
     *
     * conmakehash cp437.uni > [this file]
     *
     */

i.e. it strips the directory path of the chartable source file used.

See my patch closely.

I deleted the line "* conmakehash %s > [this file]\n\"

Quoted 63 lines

Regards
Max

Quoted 60 lines

BTW, another series of excessive efforts for a comment header can be seen in the following:

- 5ef6dc08cfde ("lib/build_OID_registry: don't mention the full path of the script in output")
- 2fe29fe94563 ("lib/build_OID_registry: avoid non-destructive substitution for Perl < 5.13.2 compat")

[1]: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html

Fixes 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env")

---

 drivers/tty/vt/conmakehash.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/tty/vt/conmakehash.c +2 -10
index 82d9db68b2ce..a931fcde7ad9 100644
@@ -11,8 +11,6 @@
  * Copyright (C) 1995-1997 H. Peter Anvin
  */
 
-#include <libgen.h>
-#include <linux/limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sysexits.h>
@@ -79,7 +77,6 @@ int main(int argc, char *argv[])
 {
   FILE *ctbl;
   const char *tblname;
-  char base_tblname[PATH_MAX];
   char buffer[65536];
   int fontlen;
   int i, nuni, nent;
@@ -245,20 +242,15 @@ int main(int argc, char *argv[])
   for ( i = 0 ; i < fontlen ; i++ )
     nuni += unicount[i];
 
-  strncpy(base_tblname, tblname, PATH_MAX);
-  base_tblname[PATH_MAX - 1] = 0;
   printf("\
 /*\n\
- * Do not edit this file; it was automatically generated by\n\
- *\n\
- * conmakehash %s > [this file]\n\
- *\n\
+ * Automatically generated file; Do not edit.\n\
  */\n\
 \n\
 #include <linux/types.h>\n\
 \n\
 u8 dfont_unicount[%d] = \n\
-{\n\t", basename(base_tblname), fontlen);
+{\n\t", fontlen);
 
Quoted 5 lines
Quoted 5 lines
drivers/tty/vt/conmakehash.c +0 -1
   for ( i = 0 ; i < fontlen ; i++ )
     {
--

2.43.0

--
Best Regards

Masahiro Yamada

#3 lore raw
Quoted 58 lines · Masahiro Yamada
Quoted 11 lines · Max Krummenacher
Quoted 8 lines · Masahiro Yamada

Commit 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env") included <linux/limits.h>, which invoked another (wrong) patch that tried to address a build error on macOS.

According to the specification [1], the correct header to use PATH_MAX is <limits.h>.

The minimal fix would be to replace <linux/limits.h> with <limits.h>.

I can change that in a v2.

You cannot.

Your buggy commit already landed in Linus' tree:

https://github.com/torvalds/linux/commit/6e20753da6bc651e02378a0cdb78f16c42098c88

Quoted 28 lines
Quoted 9 lines

However, the following commits seem questionable to me:

- 3bd85c6c97b2 ("tty: vt: conmakehash: Don't mention the full path of the input in output")
- 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env")

These commits made too many efforts to cope with a comment header in drivers/tty/vt/consolemap_deftbl.c:

Quoted 6 lines

/*
* Do not edit this file; it was automatically generated by *
* conmakehash drivers/tty/vt/cp437.uni > [this file] *
*/

This is the output you get when keeping the build artifacts within the linux source tree.
However if you keep the artifacts outside the source tree (make O=/somepath ...) the output looks like this:

    /*
     * Do not edit this file; it was automatically generated by
     *
     * conmakehash /path-to-kernel-source-tree/drivers/tty/vt/cp437.uni > [this file]
     *
     */
Quoted 3 lines

i.e. it does keep a reference to where in your filesystem the kernel source did reside when building which is against the goal of having a reproducable build.

Quoted 4 lines

You do not need to educate me.

It is well described in commit 3bd85c6c97b2d232638594bf828de62083fe3389 and I know how it works.

Sorry about that. I read your new commit as a comment to mine. Thanks for fixing the bug I added.

Regards
Max

Quoted 112 lines
Quoted 14 lines
Quoted 10 lines

With this commit, the header part of the generate C file will be simplified as follows:

/*
* Automatically generated file; Do not edit.
*/

This is not what I observed, for me with this proposed commit the comment becomes with or without the 'O=somepath':

Quoted 8 lines
    /*
     * Do not edit this file; it was automatically generated by
     *
     * conmakehash cp437.uni > [this file]
     *
     */

i.e. it strips the directory path of the chartable source file used.

See my patch closely.

I deleted the line "* conmakehash %s > [this file]\n\"

Quoted 63 lines

Regards
Max

Quoted 60 lines

BTW, another series of excessive efforts for a comment header can be seen in the following:

- 5ef6dc08cfde ("lib/build_OID_registry: don't mention the full path of the script in output")
- 2fe29fe94563 ("lib/build_OID_registry: avoid non-destructive substitution for Perl < 5.13.2 compat")

[1]: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html

Fixes 6e20753da6bc ("tty: vt: conmakehash: cope with abs_srctree no longer in env")

---

 drivers/tty/vt/conmakehash.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/tty/vt/conmakehash.c +2 -10
index 82d9db68b2ce..a931fcde7ad9 100644
@@ -11,8 +11,6 @@
  * Copyright (C) 1995-1997 H. Peter Anvin
  */
 
-#include <libgen.h>
-#include <linux/limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sysexits.h>
@@ -79,7 +77,6 @@ int main(int argc, char *argv[])
 {
   FILE *ctbl;
   const char *tblname;
-  char base_tblname[PATH_MAX];
   char buffer[65536];
   int fontlen;
   int i, nuni, nent;
@@ -245,20 +242,15 @@ int main(int argc, char *argv[])
   for ( i = 0 ; i < fontlen ; i++ )
     nuni += unicount[i];
 
-  strncpy(base_tblname, tblname, PATH_MAX);
-  base_tblname[PATH_MAX - 1] = 0;
   printf("\
 /*\n\
- * Do not edit this file; it was automatically generated by\n\
- *\n\
- * conmakehash %s > [this file]\n\
- *\n\
+ * Automatically generated file; Do not edit.\n\
  */\n\
 \n\
 #include <linux/types.h>\n\
 \n\
 u8 dfont_unicount[%d] = \n\
-{\n\t", basename(base_tblname), fontlen);
+{\n\t", fontlen);
 
Quoted 5 lines
Quoted 5 lines
drivers/tty/vt/conmakehash.c +0 -1
   for ( i = 0 ; i < fontlen ; i++ )
     {
--

2.43.0

--
Best Regards

Masahiro Yamada