aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThorsten Töpper <atsutane@freethoughts.de>2025-08-14 21:34:19 +0200
committerThorsten Töpper <atsutane@freethoughts.de>2025-08-14 21:34:19 +0200
commit23d2f670808933aa20448194b2a4ff26386d7905 (patch)
tree2cd04179c3f4118738a630ef460a45e93a21fcba /include
parent5667b14ca2e4fa3637ec9e13f8e2ea05eeef47dc (diff)
downloadsmall-utils-23d2f670808933aa20448194b2a4ff26386d7905.tar.gz
small-utils-23d2f670808933aa20448194b2a4ff26386d7905.tar.bz2
tree_based_check: switch to unsigned values
Diffstat (limited to 'include')
-rw-r--r--include/hex_conversion.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/include/hex_conversion.h b/include/hex_conversion.h
index 4b97d6d..e232b8e 100644
--- a/include/hex_conversion.h
+++ b/include/hex_conversion.h
@@ -15,9 +15,9 @@
#define ishex_macro(c) ((c>='0' && c <= '9') || (c>='A' && c <= 'F') || (c>='a' && c <= 'f'))
int convert_line(char *s);
-int ishex(char c);
-char *convert_to_binary(char *hex, char *out);
-char *convert_from_binary(char *bin, size_t l, char *out);
+int ishex(unsigned char c);
+unsigned char *convert_to_binary(char *hex, unsigned char *out);
+char *convert_from_binary(unsigned char *bin, size_t l, char *out);
/* short inline functions are fine in header */
inline int convert_line(char *s) {
@@ -35,14 +35,14 @@ inline int convert_line(char *s) {
return 0;
}
-inline int ishex(char c) {
+inline int ishex(unsigned char c) {
if ((c>='0' && c <= '9') || (c>='A' && c <= 'F') || (c>='a' && c <= 'f')) {
return 1;
}
return 0;
};
-inline char *convert_to_binary(char *hex, char *out) {
+inline unsigned char *convert_to_binary(char *hex, unsigned char *out) {
char tmp[3] = {0,0,0};
size_t length, i;
if (hex == NULL) return NULL;
@@ -65,14 +65,14 @@ inline char *convert_to_binary(char *hex, char *out) {
for (i=0;i<length;i+=2) {
tmp[0] = hex[i];
tmp[1] = hex[i+1];
- out[i/2] = (char) strtol(tmp, NULL, 16);
+ out[i/2] = (unsigned char) strtol(tmp, NULL, 16);
}
return out;
}
/* Use a large buffer and complex method, as with a simple
* way there regularly were corrupt results with gcc -O2. */
-inline char *convert_from_binary(char *bin, size_t l, char *out) {
+inline char *convert_from_binary(unsigned char *bin, size_t l, char *out) {
char tmp[24];
size_t i,pos;
if (bin == NULL || l == 0) return NULL;