Antonio Vázquez Blanco has uploaded this change for review.

View Change

Rename cli_classic.h to a more adequate cli_getop.h

The header only defines getop related stuff so it seems more intuitive this way.
Also, use SPDX to reduce header comment sizes.

Change-Id: I5986828f3bdec583af6f7b02cbe1a9c45ed2000f
Signed-off-by: Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com>
---
M cli_classic.c
M cli_getopt.c
D include/cli_classic.h
A include/cli_getopt.h
4 files changed, 50 insertions(+), 68 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/83/84983/1
diff --git a/cli_classic.c b/cli_classic.c
index 3343438..3b6b6c8 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -24,7 +24,7 @@
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <cli_classic.h>
+#include "cli_getopt.h"
#include "flash.h"
#include "flashchips.h"
#include "fmap.h"
diff --git a/cli_getopt.c b/cli_getopt.c
index fc51fcf..8e5a330 100644
--- a/cli_getopt.c
+++ b/cli_getopt.c
@@ -1,37 +1,21 @@
/*
* This file is part of the flashrom project.
- * It comes originally from the musl libc project and is licensed under the
- * terms of the MIT license.
+ * It comes originally from the musl libc project.
*
- * Copyringht (C) 2023 Rich Felker and the musl authors
- * Adjusted for flashrom by Thomas Heijligen<thomas.heijligen@secunet.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * SPDX-FileCopyrightText: 2023 Rich Felker and the musl authors
+ * SPDX-FileCopyrightText: Thomas Heijligen <thomas.heijligen@secunet.com>
+ * SPDX-FileCopyrightText: 2024 Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com>
+ * SPDX-License-Identifier: MIT
*/

+#include "cli_getopt.h"
+
#include <unistd.h>
#include <wchar.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
-#include "cli_classic.h"
-#include "flash.h"
+#include "flash.h" // msg_gerr

char *optarg;
int optind=1, opterr=1, optopt, optpos;
diff --git a/include/cli_classic.h b/include/cli_classic.h
deleted file mode 100644
index eb1f0fe..0000000
--- a/include/cli_classic.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is part of the flashrom project.
- *
- * 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.
- */
-
-#ifndef CLI_CLASSIC_H
-#define CLI_CLASSIC_H
-
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#else
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-struct option {
- const char *name;
- int has_arg;
- int *flag;
- int val;
-};
-
-int getopt (int argc, char *const *argv, const char *shortopts);
-int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-int getopt_long_only (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-
-#endif /* HAVE_GETOPT_H */
-#endif /* CLI_CLASSIC_H */
diff --git a/include/cli_getopt.h b/include/cli_getopt.h
new file mode 100644
index 0000000..5c84828
--- /dev/null
+++ b/include/cli_getopt.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * SPDX-FileCopyrightText: 2024 Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com>
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __CLI_GETOPT_H__
+#define __CLI_GETOPT_H__
+
+/**
+ * This header is responsible for either including a standard getop
+ * implementation header or to provide a compatible one.
+ */
+
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+struct option {
+ const char *name;
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+int getopt (int argc, char *const *argv, const char *shortopts);
+int getopt_long (int argc, char *const *argv, const char *shortopts,
+ const struct option *longopts, int *longind);
+int getopt_long_only (int argc, char *const *argv, const char *shortopts,
+ const struct option *longopts, int *longind);
+
+#endif /* HAVE_GETOPT_H */
+#endif /* __CLI_GETOPT_H__ */

To view, visit change 84983. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: I5986828f3bdec583af6f7b02cbe1a9c45ed2000f
Gerrit-Change-Number: 84983
Gerrit-PatchSet: 1
Gerrit-Owner: Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com>