openocd: src: replace SPDX to remaining files
[fw/openocd] / src / helper / binarybuffer.h
index b035779af571b70782956b6873af13e613d6a7d7..a8a5ef8f3f28ce9c9857305a1836d12acbcda092 100644 (file)
@@ -1,22 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
 /***************************************************************************
  *   Copyright (C) 2004, 2005 by Dominic Rath                              *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
  *   Copyright (C) 2007,2008 Ã˜yvind Harboe                                 *
  *   oyvind.harboe@zylin.com                                               *
- *                                                                         *
- *   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/>. *
  ***************************************************************************/
 
 #ifndef OPENOCD_HELPER_BINARYBUFFER_H
@@ -33,6 +22,7 @@
  * using the bits in @c value.  This routine fast-paths writes
  * of little-endian, byte-aligned, 32-bit words.
  * @param _buffer The buffer whose bits will be set.
+ *     Do not use uninitialized buffer or clang static analyzer emits a warning.
  * @param first The bit offset in @c _buffer to start writing (0-31).
  * @param num The number of bits from @c value to copy (1-32).
  * @param value Up to 32 bits that will be copied to _buffer.
@@ -62,6 +52,7 @@ static inline void buf_set_u32(uint8_t *_buffer,
  * using the bits in @c value.  This routine fast-paths writes
  * of little-endian, byte-aligned, 64-bit words.
  * @param _buffer The buffer whose bits will be set.
+ *     Do not use uninitialized buffer or clang static analyzer emits a warning.
  * @param first The bit offset in @c _buffer to start writing (0-63).
  * @param num The number of bits from @c value to copy (1-64).
  * @param value Up to 64 bits that will be copied to _buffer.
@@ -118,7 +109,7 @@ static inline uint32_t buf_get_u32(const uint8_t *_buffer,
                uint32_t result = 0;
                for (unsigned i = first; i < first + num; i++) {
                        if (((buffer[i / 8] >> (i % 8)) & 1) == 1)
-                               result |= 1 << (i - first);
+                               result |= 1U << (i - first);
                }
                return result;
        }
@@ -199,7 +190,7 @@ void *buf_set_buf(const void *src, unsigned src_start,
 
 int str_to_buf(const char *str, unsigned len,
                void *bin_buf, unsigned buf_size, unsigned radix);
-char *buf_to_str(const void *buf, unsigned size, unsigned radix);
+char *buf_to_hex_str(const void *buf, unsigned size);
 
 /* read a uint32_t from a buffer in target memory endianness */
 static inline uint32_t fast_target_buffer_get_u32(const void *p, bool le)
@@ -235,7 +226,7 @@ void bit_copy_discard(struct bit_copy_queue *q);
 /* functions to convert to/from hex encoded buffer
  * used in ti-icdi driver and gdb server */
 size_t unhexify(uint8_t *bin, const char *hex, size_t count);
-int hexify(char *hex, const char *bin, int count, int out_maxlen);
+size_t hexify(char *hex, const uint8_t *bin, size_t count, size_t out_maxlen);
 void buffer_shr(void *_buf, unsigned buf_len, unsigned count);
 
 #endif /* OPENOCD_HELPER_BINARYBUFFER_H */