hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/scripts/dtc/util.h
....@@ -1,6 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 #ifndef UTIL_H
23 #define UTIL_H
34
5
+#include <stdlib.h>
46 #include <stdarg.h>
57 #include <stdbool.h>
68 #include <getopt.h>
....@@ -8,25 +10,14 @@
810 /*
911 * Copyright 2011 The Chromium Authors, All Rights Reserved.
1012 * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
11
- *
12
- * This program is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU General Public License as
14
- * published by the Free Software Foundation; either version 2 of the
15
- * License, or (at your option) any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
- * General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; if not, write to the Free Software
24
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25
- * USA
2613 */
2714
2815 #ifdef __GNUC__
16
+#ifdef __clang__
2917 #define PRINTF(i, j) __attribute__((format (printf, i, j)))
18
+#else
19
+#define PRINTF(i, j) __attribute__((format (gnu_printf, i, j)))
20
+#endif
3021 #define NORETURN __attribute__((noreturn))
3122 #else
3223 #define PRINTF(i, j)
....@@ -72,6 +63,8 @@
7263 extern char *xstrdup(const char *s);
7364
7465 extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...);
66
+extern int PRINTF(2, 3) xasprintf_append(char **strp, const char *fmt, ...);
67
+extern int xavsprintf_append(char **strp, const char *fmt, va_list ap);
7568 extern char *join_path(const char *path, const char *name);
7669
7770 /**
....@@ -98,16 +91,10 @@
9891 * stderr.
9992 *
10093 * @param filename The filename to read, or - for stdin
94
+ * @param len If non-NULL, the amount of data we managed to read
10195 * @return Pointer to allocated buffer containing fdt, or NULL on error
10296 */
103
-char *utilfdt_read(const char *filename);
104
-
105
-/**
106
- * Like utilfdt_read(), but also passes back the size of the file read.
107
- *
108
- * @param len If non-NULL, the amount of data we managed to read
109
- */
110
-char *utilfdt_read_len(const char *filename, off_t *len);
97
+char *utilfdt_read(const char *filename, size_t *len);
11198
11299 /**
113100 * Read a device tree file into a buffer. Does not report errors, but only
....@@ -116,23 +103,17 @@
116103 *
117104 * @param filename The filename to read, or - for stdin
118105 * @param buffp Returns pointer to buffer containing fdt
106
+ * @param len If non-NULL, the amount of data we managed to read
119107 * @return 0 if ok, else an errno value representing the error
120108 */
121
-int utilfdt_read_err(const char *filename, char **buffp);
122
-
123
-/**
124
- * Like utilfdt_read_err(), but also passes back the size of the file read.
125
- *
126
- * @param len If non-NULL, the amount of data we managed to read
127
- */
128
-int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len);
109
+int utilfdt_read_err(const char *filename, char **buffp, size_t *len);
129110
130111 /**
131112 * Write a device tree buffer to a file. This will report any errors on
132113 * stderr.
133114 *
134115 * @param filename The filename to write, or - for stdout
135
- * @param blob Poiner to buffer containing fdt
116
+ * @param blob Pointer to buffer containing fdt
136117 * @return 0 if ok, -1 on error
137118 */
138119 int utilfdt_write(const char *filename, const void *blob);
....@@ -143,7 +124,7 @@
143124 * an error message for the user.
144125 *
145126 * @param filename The filename to write, or - for stdout
146
- * @param blob Poiner to buffer containing fdt
127
+ * @param blob Pointer to buffer containing fdt
147128 * @return 0 if ok, else an errno value representing the error
148129 */
149130 int utilfdt_write_err(const char *filename, const void *blob);