Skip to content

Commit dc1a920

Browse files
committed
Fix indentation
1 parent ffdd841 commit dc1a920

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

Diff for: cores/esp32/HEXBuilder.cpp

+34-32
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*
1+
/*
22
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
3-
This file is part of the esp8266 core for Arduino environment.
4-
3+
This file is part of the esp32 core for Arduino environment.
4+
55
This library is free software; you can redistribute it and/or
66
modify it under the terms of the GNU Lesser General Public
77
License as published by the Free Software Foundation; either
@@ -16,6 +16,7 @@
1616
License along with this library; if not, write to the Free Software
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
19+
1920
#include <Arduino.h>
2021
#include <HEXBuilder.h>
2122

@@ -27,43 +28,44 @@ static uint8_t hex_char_to_byte(uint8_t c)
2728
}
2829

2930
size_t HEXBuilder::hex2bytes(unsigned char * out, size_t maxlen, String &in) {
30-
return hex2bytes(out, maxlen, in.c_str());
31+
return hex2bytes(out, maxlen, in.c_str());
3132
}
3233

3334
size_t HEXBuilder::hex2bytes(unsigned char * out, size_t maxlen, const char * in) {
34-
size_t len = 0;
35-
for(;*in;in++) {
36-
uint8_t c = hex_char_to_byte(*in);
37-
// Silently skip anything unknown.
38-
if (c > 15)
39-
continue;
35+
size_t len = 0;
36+
for(;*in;in++) {
37+
uint8_t c = hex_char_to_byte(*in);
38+
// Silently skip anything unknown.
39+
if (c > 15)
40+
continue;
4041

41-
if (len & 1) {
42-
if (len/2 < maxlen)
43-
out[len/2] |= c;
44-
} else {
45-
if (len/2 < maxlen)
46-
out[len/2] = c<<4;
47-
}
48-
len++;
49-
}
50-
return (len + 1)/2;
42+
if (len & 1) {
43+
if (len/2 < maxlen)
44+
out[len/2] |= c;
45+
} else {
46+
if (len/2 < maxlen)
47+
out[len/2] = c<<4;
48+
}
49+
len++;
50+
}
51+
return (len + 1)/2;
5152
}
5253

5354
size_t HEXBuilder::bytes2hex(char * out, size_t maxlen, const unsigned char * in, size_t len) {
54-
for(size_t i = 0; i < len; i++)
55-
if (i*2 + 1 < maxlen)
56-
sprintf(out + (i * 2), "%02x", in[i]);
57-
58-
return len * 2 + 1;
55+
for(size_t i = 0; i < len; i++) {
56+
if (i*2 + 1 < maxlen) {
57+
sprintf(out + (i * 2), "%02x", in[i]);
58+
}
59+
}
60+
return len * 2 + 1;
5961
}
6062

6163
String HEXBuilder::bytes2hex(const unsigned char * in, size_t len) {
62-
size_t maxlen = len * 2 + 1;
63-
char * out = (char *) malloc(maxlen);
64-
if (!out) return String();
65-
bytes2hex(out, maxlen, in, len);
66-
String ret = String(out);
67-
free(out);
68-
return ret;
64+
size_t maxlen = len * 2 + 1;
65+
char * out = (char *) malloc(maxlen);
66+
if (!out) return String();
67+
bytes2hex(out, maxlen, in, len);
68+
String ret = String(out);
69+
free(out);
70+
return ret;
6971
}

Diff for: cores/esp32/HEXBuilder.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*
1+
/*
22
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
33
This file is part of the esp8266 core for Arduino environment.
4-
4+
55
This library is free software; you can redistribute it and/or
66
modify it under the terms of the GNU Lesser General Public
77
License as published by the Free Software Foundation; either

0 commit comments

Comments
 (0)