diff mbox series

[v2,1/2] linux-user: Move the SPDX license identifier to first line

Message ID 20211104071541.3813306-2-f4bug@amsat.org
State New
Headers show
Series linux-user: Add GPL-2.0-or-later SPDX license identifier | expand

Commit Message

Philippe Mathieu-Daudé Nov. 4, 2021, 7:15 a.m. UTC
Tools consuming SPDX license identifiers benefit from having
the SPDX tag in its own comment, not embedded with the license
text. Move the tag to the first line.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 linux-user/semihost.c   | 3 +--
 linux-user/errnos.c.inc | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

Comments

Daniel P. Berrangé Nov. 4, 2021, 9:13 a.m. UTC | #1
On Thu, Nov 04, 2021 at 08:15:40AM +0100, Philippe Mathieu-Daudé wrote:
> Tools consuming SPDX license identifiers benefit from having
> the SPDX tag in its own comment, not embedded with the license
> text. Move the tag to the first line.

Do you have an example of such a tool which has problems ?

AFAIK, guidance for adding SPDX tags merely says they should
be in a comment near the top of the file.

I wouldn't expect license scanners to care about the acutal
comment syntax. Proper tools would be designed to scan for
tags in *any* file format, so would be unlikely to be parsing
the C code comments at all. Rather scanners would be just
looking for the magic string "SPDX-License-Identifier" in
the file. Use of comments is merely to stop the C compiler
interpreting the tag.

It makes sense to have the SPDX tag as the first thing in
the file, but I don't see a compelling need to make it into
its own dedicated opened + closed comment, separately from
the license header comment.

Regards,
Daniel
Warner Losh Nov. 9, 2021, 5:02 p.m. UTC | #2
> On Nov 4, 2021, at 3:13 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
> 
> On Thu, Nov 04, 2021 at 08:15:40AM +0100, Philippe Mathieu-Daudé wrote:
>> Tools consuming SPDX license identifiers benefit from having
>> the SPDX tag in its own comment, not embedded with the license
>> text. Move the tag to the first line.
> 
> Do you have an example of such a tool which has problems ?
> 
> AFAIK, guidance for adding SPDX tags merely says they should
> be in a comment near the top of the file.
> 
> I wouldn't expect license scanners to care about the acutal
> comment syntax. Proper tools would be designed to scan for
> tags in *any* file format, so would be unlikely to be parsing
> the C code comments at all. Rather scanners would be just
> looking for the magic string "SPDX-License-Identifier" in
> the file. Use of comments is merely to stop the C compiler
> interpreting the tag.
> 
> It makes sense to have the SPDX tag as the first thing in
> the file, but I don't see a compelling need to make it into
> its own dedicated opened + closed comment, separately from
> the license header comment.

The SPDX’s tools don’t require the proposed changes. Nor does
the SPDX standard which says that the lines can be anywhere in the
file. The reuse.software additions to this standard add additional
ways to mark binary files, but otherwise says the same thing.

The FreeBSD project has been marking files with SPDX tags for years
and has never once encountered this issue.

Warner

> Regards,
> Daniel
> -- 
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
> 
>
diff mbox series

Patch

diff --git a/linux-user/semihost.c b/linux-user/semihost.c
index 17f074ac565..df1de3131d4 100644
--- a/linux-user/semihost.c
+++ b/linux-user/semihost.c
@@ -1,30 +1,29 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
  * ARM Compatible Semihosting Console Support.
  *
  * Copyright (c) 2019 Linaro Ltd
  *
  * Currently ARM and RISC-V are unique in having support for
  * semihosting support in linux-user. So for now we implement the
  * common console API but just for arm and risc-v linux-user.
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include "qemu/osdep.h"
 #include "semihosting/console.h"
 #include "qemu.h"
 #include "user-internals.h"
 #include <termios.h>
 
 int qemu_semihosting_console_outs(CPUArchState *env, target_ulong addr)
 {
     int len = target_strlen(addr);
     void *s;
     if (len < 0){
        qemu_log_mask(LOG_GUEST_ERROR,
                      "%s: passed inaccessible address " TARGET_FMT_lx,
                      __func__, addr);
        return 0;
     }
     s = lock_user(VERIFY_READ, addr, (long)(len + 1), 1);
     g_assert(s);  /* target_strlen has already verified this will work */
diff --git a/linux-user/errnos.c.inc b/linux-user/errnos.c.inc
index 963ba1ce9d1..2fa8b78705b 100644
--- a/linux-user/errnos.c.inc
+++ b/linux-user/errnos.c.inc
@@ -1,42 +1,41 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
  * This list is the union of errno values overridden in asm-<arch>/errno.h
  * minus the errnos that are not actually generic to all archs.
  *
  * Please keep this list sorted alphabetically.
  *
  *  Copyright (c) 2003 Fabrice Bellard
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 E(EADDRINUSE)
 E(EADDRNOTAVAIL)
 E(EADV)
 E(EAFNOSUPPORT)
 E(EAGAIN)
 E(EALREADY)
 E(EBADE)
 E(EBADFD)
 E(EBADMSG)
 E(EBADR)
 E(EBADRQC)
 E(EBADSLT)
 E(EBFONT)
 E(ECANCELED)
 E(ECHRNG)
 E(ECOMM)
 E(ECONNABORTED)
 E(ECONNREFUSED)