Skip to content

Commit b19a2a4

Browse files
authored
Apply clang-format with adapted settings (#81)
1 parent 36fc784 commit b19a2a4

57 files changed

Lines changed: 1132 additions & 1178 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
BasedOnStyle: LLVM
2+
ColumnLimit: 100
3+
IndentWidth: 4
4+
TabWidth: 4
5+
UseTab: ForContinuationAndIndentation
6+
AlignTrailingComments: true

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
end_of_line = lf
9+
insert_final_newline = true
10+
11+
# Tab indentation (no size specified)
12+
[Makefile]
13+
indent_style = tab
14+
15+
[*.{c,h,cpp,hpp}]
16+
indent_size = 4

.travis.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,30 @@ language: c
22

33
sudo: false
44

5-
compiler:
6-
- clang
7-
- gcc
8-
95
addons:
106
apt:
7+
sources:
8+
- llvm-toolchain-trusty
119
packages:
12-
- uuid-dev
13-
- uuid-runtime
10+
- clang-format-9
11+
- uuid-dev
12+
- uuid-runtime
13+
14+
before_script:
15+
- clang-format --version
16+
17+
matrix:
18+
include:
19+
- env: BUILD=1
20+
compiler: clang
21+
- env: BUILD=1
22+
compiler: gcc
23+
- env: FORMAT=1
1424

1525
script:
16-
- make
26+
- if [ -n "$BUILD" ]; then make; fi
27+
- |
28+
if [ -n "$FORMAT" ]; then
29+
clang-format -i sml/include/sml/* sml/src/*
30+
test -z "$(git status --porcelain)" || (git status; git diff; false)
31+
fi

sml/include/sml/sml_attention_response.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@
1717
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
1818

1919
#ifndef SML_ATTENTION_RESPONSE_H_
20-
#define SML_ATTENTION_RESPONSE_H_
20+
#define SML_ATTENTION_RESPONSE_H_
2121

22-
#include "sml_shared.h"
2322
#include "sml_octet_string.h"
23+
#include "sml_shared.h"
2424
#include "sml_tree.h"
2525

2626
#ifdef __cplusplus
2727
extern "C" {
2828
#endif
2929

30-
3130
typedef struct {
3231
octet_string *server_id;
3332
octet_string *attention_number;
3433
octet_string *attention_message; // optional
35-
sml_tree *attention_details; // optional
34+
sml_tree *attention_details; // optional
3635
} sml_attention_response;
3736

3837
sml_attention_response *sml_attention_response_init();
@@ -44,6 +43,4 @@ void sml_attention_response_free(sml_attention_response *msg);
4443
}
4544
#endif
4645

47-
4846
#endif /* SML_ATTENTION_RESPONSE_H_ */
49-

sml/include/sml/sml_boolean.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
1818

1919
#ifndef SML_BOOLEAN_H_
20-
#define SML_BOOLEAN_H_
20+
#define SML_BOOLEAN_H_
2121

2222
#define SML_BOOLEAN_TRUE 0xFF
2323
#define SML_BOOLEAN_FALSE 0x00
@@ -39,6 +39,4 @@ void sml_boolean_free(sml_boolean *b);
3939
}
4040
#endif
4141

42-
4342
#endif /* SML_BOOLEAN_H_ */
44-

sml/include/sml/sml_close_request.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#ifndef SML_CLOSE_REQUEST_H_
2020
#define SML_CLOSE_REQUEST_H_
2121

22-
#include "sml_shared.h"
2322
#include "sml_octet_string.h"
23+
#include "sml_shared.h"
2424

2525
#ifdef __cplusplus
2626
extern "C" {
@@ -31,14 +31,12 @@ typedef struct {
3131
} sml_close_request;
3232

3333
sml_close_request *sml_close_request_init();
34-
sml_close_request * sml_close_request_parse(sml_buffer *buf);
34+
sml_close_request *sml_close_request_parse(sml_buffer *buf);
3535
void sml_close_request_write(sml_close_request *msg, sml_buffer *buf);
3636
void sml_close_request_free(sml_close_request *msg);
3737

3838
#ifdef __cplusplus
3939
}
4040
#endif
4141

42-
4342
#endif /* SML_CLOSE_REQUEST_H_ */
44-

sml/include/sml/sml_close_response.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,4 @@ void sml_close_response_free(sml_close_response *msg);
3636
}
3737
#endif
3838

39-
4039
#endif /* SML_CLOSE_RESPONSE_H_ */
41-

sml/include/sml/sml_crc16.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ extern "C" {
2626
#endif
2727

2828
// CRC16 FSC implementation based on DIN 62056-46
29-
u16 sml_crc16_calculate(unsigned char *cp, int len) ;
29+
u16 sml_crc16_calculate(unsigned char *cp, int len);
3030

3131
// CRC-16/CCITT(Kermit) implementation poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000
32-
u16 sml_crc16kermit_calculate(unsigned char *cp, int len) ;
32+
u16 sml_crc16kermit_calculate(unsigned char *cp, int len);
3333

3434
#ifdef __cplusplus
3535
}
3636
#endif
3737

38-
3938
#endif /* SML_CRC16_H_ */
40-

sml/include/sml/sml_file.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
1818

1919
#ifndef SML_FILE_H_
20-
#define SML_FILE_H_
20+
#define SML_FILE_H_
2121

2222
#include "sml_message.h"
2323
#include "sml_shared.h"
@@ -29,9 +29,9 @@ extern "C" {
2929

3030
// a SML file consist of multiple SML messages
3131
typedef struct {
32-
sml_message **messages;
33-
short messages_len;
34-
sml_buffer *buf;
32+
sml_message **messages;
33+
short messages_len;
34+
sml_buffer *buf;
3535
} sml_file;
3636

3737
sml_file *sml_file_init();
@@ -46,6 +46,4 @@ void sml_file_print(sml_file *file);
4646
}
4747
#endif
4848

49-
5049
#endif /* SML_FILE_H_ */
51-

sml/include/sml/sml_get_list_request.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@
1919
#ifndef SML_GET_LIST_REQUEST_H_
2020
#define SML_GET_LIST_REQUEST_H_
2121

22-
#include "sml_shared.h"
22+
#include "sml_list.h"
2323
#include "sml_octet_string.h"
24+
#include "sml_shared.h"
2425
#include "sml_time.h"
25-
#include "sml_list.h"
2626

2727
#ifdef __cplusplus
2828
extern "C" {
2929
#endif
3030

3131
typedef struct {
3232
octet_string *client_id;
33-
octet_string *server_id; // optional
34-
octet_string *username; // optional
35-
octet_string *password; // optional
36-
octet_string *list_name; // optional
33+
octet_string *server_id; // optional
34+
octet_string *username; // optional
35+
octet_string *password; // optional
36+
octet_string *list_name; // optional
3737
} sml_get_list_request;
3838

39-
sml_get_list_request* sml_get_list_request_init();
39+
sml_get_list_request *sml_get_list_request_init();
4040
sml_get_list_request *sml_get_list_request_parse(sml_buffer *buf);
4141
void sml_get_list_request_write(sml_get_list_request *msg, sml_buffer *buf);
4242
void sml_get_list_request_free(sml_get_list_request *msg);
@@ -45,6 +45,4 @@ void sml_get_list_request_free(sml_get_list_request *msg);
4545
}
4646
#endif
4747

48-
4948
#endif /* SML_GET_LIST_REQUEST_H_ */
50-

0 commit comments

Comments
 (0)