Skip to content

Commit 81ae024

Browse files
pjungkampstv0g
authored andcommitted
fix(clang-format): Proper formatting for libjansson macros
Signed-off-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
1 parent e93347f commit 81ae024

Some content is hidden

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

48 files changed

+87
-78
lines changed

.clang-format

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ IncludeCategories:
2222
Priority: 2
2323
- Regex: '^".*"$'
2424
Priority: 4
25+
26+
# Add libjansson foreach macros
27+
ForEachMacros:
28+
- 'json_array_foreach'
29+
- 'json_object_foreach'
30+
- 'json_object_foreach_safe'
31+
- 'json_object_keylen_foreach'
32+
- 'json_object_keylen_foreach_safe'

common/lib/log.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ void Log::parse(json_t *json) {
141141
json_t *json_expression;
142142

143143
// cppcheck-suppress unknownMacro
144-
json_array_foreach(json_expressions, i, json_expression)
145-
expressions.emplace_back(json_expression);
144+
json_array_foreach (json_expressions, i, json_expression)
145+
expressions.emplace_back(json_expression);
146146
}
147147
}
148148

fpga/include/villas/fpga/card_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CardParser {
4444
// Parse ignored ip names to list
4545
size_t index;
4646
json_t *value;
47-
json_array_foreach(ignored_ips_array, index, value) {
47+
json_array_foreach (ignored_ips_array, index, value) {
4848
ignored_ip_names.push_back(json_string_value(value));
4949
}
5050

fpga/lib/card.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void CardFactory::loadSwitch(std::shared_ptr<Card> card, json_t *json_paths) {
179179

180180
size_t i;
181181
json_t *json_path;
182-
json_array_foreach(json_paths, i, json_path) {
182+
json_array_foreach (json_paths, i, json_path) {
183183
const char *from, *to;
184184
int reverse = 0;
185185

fpga/lib/core.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ std::list<IpIdentifier> CoreFactory::parseIpIdentifier(json_t *json_ips) {
4444

4545
const char *ipName;
4646
json_t *json_ip;
47-
json_object_foreach(json_ips, ipName, json_ip) {
47+
json_object_foreach (json_ips, ipName, json_ip) {
4848
const char *vlnv;
4949

5050
json_error_t err;
@@ -168,7 +168,7 @@ CoreFactory::configureIps(std::list<IpIdentifier> orderedIps, json_t *json_ips,
168168

169169
const char *irqName;
170170
json_t *json_irq;
171-
json_object_foreach(json_irqs, irqName, json_irq) {
171+
json_object_foreach (json_irqs, irqName, json_irq) {
172172
const char *irqEntry = json_string_value(json_irq);
173173

174174
auto tokens = utils::tokenize(irqEntry, ":");
@@ -223,7 +223,7 @@ CoreFactory::configureIps(std::list<IpIdentifier> orderedIps, json_t *json_ips,
223223
// Now find all slave address spaces this master can access
224224
const char *bus_name;
225225
json_t *json_bus;
226-
json_object_foreach(json_memory_view, bus_name, json_bus) {
226+
json_object_foreach (json_memory_view, bus_name, json_bus) {
227227

228228
// This IP has a memory view => it is a bus master somewhere
229229

@@ -239,11 +239,11 @@ CoreFactory::configureIps(std::list<IpIdentifier> orderedIps, json_t *json_ips,
239239

240240
const char *instance_name;
241241
json_t *json_instance;
242-
json_object_foreach(json_bus, instance_name, json_instance) {
242+
json_object_foreach (json_bus, instance_name, json_instance) {
243243

244244
const char *block_name;
245245
json_t *json_block;
246-
json_object_foreach(json_instance, block_name, json_block) {
246+
json_object_foreach (json_instance, block_name, json_block) {
247247

248248
json_int_t base, high, size;
249249
json_error_t err;

fpga/lib/ips/pcie.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void AxiPciExpressBridgeFactory::parse(Core &ip, json_t *cfg) {
111111

112112
json_t *json_bar;
113113
const char *bar_name;
114-
json_object_foreach(json_bars, bar_name, json_bar) {
114+
json_object_foreach (json_bars, bar_name, json_bar) {
115115
unsigned int translation;
116116

117117
json_error_t err;

fpga/lib/node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void NodeFactory::parse(Core &ip, json_t *cfg) {
3030
if (json_ports && json_is_array(json_ports)) {
3131
size_t index;
3232
json_t *json_port;
33-
json_array_foreach(json_ports, index, json_port) {
33+
json_array_foreach (json_ports, index, json_port) {
3434
if (not json_is_object(json_port))
3535
throw ConfigError(json_port, "", "Port {} is not an object", index);
3636

fpga/lib/pcie_card.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ PCIeCardFactory::make(json_t *json_card, std::string card_name,
7070
// Parse ignored ip names to list
7171
size_t index;
7272
json_t *value;
73-
json_array_foreach(ignored_ips_array, index, value) {
73+
json_array_foreach (ignored_ips_array, index, value) {
7474
card->ignored_ip_names.push_back(json_string_value(value));
7575
}
7676

fpga/lib/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ int fpga::createCards(json_t *config,
280280
const char *card_name;
281281
json_t *json_card;
282282
std::shared_ptr<fpga::Card> card;
283-
json_object_foreach(fpgas, card_name, json_card) {
283+
json_object_foreach (fpgas, card_name, json_card) {
284284
card = createCard(json_card, searchPath, vfioContainer, card_name);
285285
if (card != nullptr) {
286286
cards.push_back(card);

lib/api/universal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void ChannelList::parse(json_t *json, bool readable, bool writable) {
2222

2323
size_t i;
2424
json_t *json_channel;
25-
json_array_foreach(json, i, json_channel) {
25+
json_array_foreach (json, i, json_channel) {
2626
auto channel = std::make_shared<Channel>();
2727

2828
channel->parse(json_channel);
@@ -73,7 +73,7 @@ void Channel::parse(json_t *json) {
7373

7474
range_options.clear();
7575

76-
json_array_foreach(json_range, i, json_option) {
76+
json_array_foreach (json_range, i, json_option) {
7777
if (!json_is_string(json_option))
7878
throw ConfigError(json, err, "node-config-node-api-signals-range",
7979
"Channel range options must be strings");

0 commit comments

Comments
 (0)