Skip to content

Commit 7a8dc4c

Browse files
committed
modify code format
1 parent a30df62 commit 7a8dc4c

Some content is hidden

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

52 files changed

+2541
-2632
lines changed

devel/mod_test.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
* Structure for test infomation.
2222
*/
2323
struct stats_test {
24-
unsigned long long value_1;
25-
unsigned long long value_2;
26-
unsigned long long value_3;
24+
unsigned long long value_1;
25+
unsigned long long value_2;
26+
unsigned long long value_3;
2727
};
2828

2929
#define STATS_TEST_SIZE (sizeof(struct stats_test))
@@ -33,44 +33,43 @@ static char *test_usage = " --test test information";
3333

3434
static void read_test_stats(struct module *mod, char *parameter)
3535
{
36-
char buf[256];
36+
char buf[256];
3737
memset(buf, 0, sizeof(buf));
38-
struct stats_test st_test;
38+
struct stats_test st_test;
3939
memset(&st_test, 0, sizeof(struct stats_test));
4040

4141
st_test.value_1 = 1;
4242
st_test.value_2 = 1;
4343
st_test.value_3 = 1;
4444

45-
int pos = sprintf(buf, "%llu,%llu,%llu",
46-
/* the store order is not same as read procedure */
47-
st_test.value_1,
48-
st_test.value_2,
49-
st_test.value_3);
45+
int pos = sprintf(buf, "%llu,%llu,%llu",
46+
/* the store order is not same as read procedure */
47+
st_test.value_1,
48+
st_test.value_2,
49+
st_test.value_3);
5050

51-
buf[pos] = '\0';
51+
buf[pos] = '\0';
5252
set_mod_record(mod, buf);
53-
return;
53+
return;
5454
}
5555

5656
static struct mod_info test_info[] = {
57-
{"value1", SUMMARY_BIT, 0, STATS_NULL},
58-
{"value2", DETAIL_BIT, 0, STATS_NULL},
59-
{"value3", DETAIL_BIT, 0, STATS_NULL}
57+
{"value1", SUMMARY_BIT, 0, STATS_NULL},
58+
{"value2", DETAIL_BIT, 0, STATS_NULL},
59+
{"value3", DETAIL_BIT, 0, STATS_NULL}
6060
};
6161

6262
static void set_cpu_record(struct module *mod, double st_array[],
63-
U_64 pre_array[], U_64 cur_array[], int inter)
63+
U_64 pre_array[], U_64 cur_array[], int inter)
6464
{
6565
int i;
66-
/* set st record */
67-
for (i = 0; i < mod->n_col; i++) {
68-
st_array[i] = cur_array[i];
69-
}
66+
/* set st record */
67+
for (i = 0; i < mod->n_col; i++) {
68+
st_array[i] = cur_array[i];
69+
}
7070
}
7171

7272
void mod_register(struct module *mod)
7373
{
7474
register_mod_fileds(mod, "--test", test_usage, test_info, 3, read_test_stats, set_cpu_record);
7575
}
76-

include/config.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ struct configure
4949
char output_db_mod[LEN_512]; /* which mod will output */
5050
char output_db_addr[LEN_512]; /* db addr */
5151

52-
/* output nagios */
53-
char server_addr[LEN_512];
54-
int *server_port;
55-
int *cycle_time;
56-
char send_nsca_cmd[LEN_512];
57-
char send_nsca_conf[LEN_512];
52+
/* output nagios */
53+
char server_addr[LEN_512];
54+
int *server_port;
55+
int *cycle_time;
56+
char send_nsca_cmd[LEN_512];
57+
char send_nsca_conf[LEN_512];
5858

59-
char check_name[MAX_MOD_NUM][LEN_32];
60-
float wmin[MAX_MOD_NUM];
61-
float wmax[MAX_MOD_NUM];
62-
float cmin[MAX_MOD_NUM];
63-
float cmax[MAX_MOD_NUM];
64-
int mod_num;
59+
char check_name[MAX_MOD_NUM][LEN_32];
60+
float wmin[MAX_MOD_NUM];
61+
float wmax[MAX_MOD_NUM];
62+
float cmin[MAX_MOD_NUM];
63+
float cmax[MAX_MOD_NUM];
64+
int mod_num;
6565

6666
/* output file */
6767
char output_file_path[LEN_128];

include/framework.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct module
6464

6565

6666
void register_mod_fileds(struct module *mod, char *opt, char *usage,
67-
struct mod_info *info, int n_col, void *data_collect, void *set_st_record);
67+
struct mod_info *info, int n_col, void *data_collect, void *set_st_record);
6868
void set_mod_record(struct module *mod, char *record);
6969
void init_module_fields();
7070
int reload_modules(char *s_mod);

include/public.h

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
#define RED_FMT(s) "\033[40;31m"s"\033[0m"
5050

5151
#define COLOR(val, fmt, str, ret, color) do \
52-
{ \
53-
if ((val) > 100) \
54-
ret = sprintf(str, \
55-
color##_FMT(fmt), (val)); \
56-
else \
57-
ret = sprintf(str, fmt, (val)); \
58-
} while(0)
52+
{ \
53+
if ((val) > 100) \
54+
ret = sprintf(str, \
55+
color##_FMT(fmt), (val)); \
56+
else \
57+
ret = sprintf(str, fmt, (val)); \
58+
} while(0)
5959

6060
#define FALSE 0
6161
#define TRUE 1
@@ -129,43 +129,43 @@ enum {MIN, MEAN, MAX};
129129

130130

131131
#define __PRINT_S(buffer, val, ret) do { \
132-
int _i; \
133-
double _f; \
134-
char u[] = {'K', 'M', 'G', 'T'}; \
135-
__INDENT((val), _i, _f); \
136-
(ret) += sprintf((buffer), FMT_S, _f, u[_i]); \
137-
}while(0)
132+
int _i; \
133+
double _f; \
134+
char u[] = {'K', 'M', 'G', 'T'}; \
135+
__INDENT((val), _i, _f); \
136+
(ret) += sprintf((buffer), FMT_S, _f, u[_i]); \
137+
}while(0)
138138

139139
#define __PRINT_SP(buffer, val, ret) do { \
140-
(ret) += sprintf(buffer, FMT_SP, (val)); \
141-
}while(0)
140+
(ret) += sprintf(buffer, FMT_SP, (val)); \
141+
}while(0)
142142

143143
#define __PRINT_NAGIOS(buffer, val, ret) do { \
144-
(ret) += sprintf(buffer, FMT_NAGIOS, (val)); \
145-
}while(0)
144+
(ret) += sprintf(buffer, FMT_NAGIOS, (val)); \
145+
}while(0)
146146

147147
#define PRINT(buffer, val, ret, type) do { \
148-
if (type == OUTPUT_NAGIOS) { \
149-
__PRINT_NAGIOS(buffer, val, ret); \
150-
} \
151-
else{ \
152-
if ((val) < KB) { \
153-
__PRINT_SP(buffer, val, ret); \
154-
} \
155-
else { \
156-
__PRINT_S(buffer, val, ret); \
157-
} \
158-
} \
159-
} while(0)
148+
if (type == OUTPUT_NAGIOS) { \
149+
__PRINT_NAGIOS(buffer, val, ret); \
150+
} \
151+
else{ \
152+
if ((val) < KB) { \
153+
__PRINT_SP(buffer, val, ret); \
154+
} \
155+
else { \
156+
__PRINT_S(buffer, val, ret); \
157+
} \
158+
} \
159+
} while(0)
160160

161161
#define myalloc(p, type, size) \
162162
struct type * p = NULL; \
163-
p = (struct type *)malloc(size); \
164-
if(!p) { \
165-
fprintf(stderr, "failed to alloc memory\n"); \
166-
exit(EXIT_FAILURE); \
167-
} \
168-
memset(p, 0, size) \
163+
p = (struct type *)malloc(size); \
164+
if(!p) { \
165+
fprintf(stderr, "failed to alloc memory\n"); \
166+
exit(EXIT_FAILURE); \
167+
} \
168+
memset(p, 0, size) \
169169

170170
#define BUFFER_ROTATE(mod, size) \
171171
do { \
@@ -175,28 +175,28 @@ enum {MIN, MEAN, MAX};
175175

176176
inline void func_mod_free(struct module *mod)
177177
{
178-
free(mod->detail);
179-
free(mod->summary);
180-
mod->detail = NULL;
181-
mod->summary = NULL;
178+
free(mod->detail);
179+
free(mod->summary);
180+
mod->detail = NULL;
181+
mod->summary = NULL;
182182
}
183183

184184
#define INIT_STRING_P(s, nr, len) \
185185
do { \
186186
int i; \
187187
s = (char **)malloc((nr) * sizeof(char *)); \
188188
for(i = 0; i < (nr); i++) \
189-
s[i] = (char *)malloc(len); \
189+
s[i] = (char *)malloc(len); \
190190
} while(0)
191191

192192

193193
#define DECLARE_TMP_MOD_STATISTICS(mod) \
194194
union mod##_statistics mod##_tmp_s; \
195-
195+
196196
#define SET_CURRENT_VALUE(mod, type, member, ret) \
197197
do { \
198198
mod##_tmp_s.mod##_##type.ret = \
199-
s_st_##mod[CURR].member; \
199+
s_st_##mod[CURR].member; \
200200
}while(0)
201201

202202
#define __COMPUTE_MOD_VALUE(ret, ops, m1, m2, i) \
@@ -217,11 +217,11 @@ inline void func_mod_free(struct module *mod)
217217
do { \
218218
/*printf("i = %ld\n", (i));*/ \
219219
__COMPUTE_MOD_VALUE( \
220-
mod##_tmp_s.mod##_##type.ret, \
221-
ops, \
222-
s_st_##mod[1].member, \
223-
s_st_##mod[0].member, \
224-
(i)); \
220+
mod##_tmp_s.mod##_##type.ret, \
221+
ops, \
222+
s_st_##mod[1].member, \
223+
s_st_##mod[0].member, \
224+
(i)); \
225225
} while(0)
226226

227227

@@ -235,7 +235,7 @@ inline void func_mod_free(struct module *mod)
235235
sw = 1; \
236236
} else { \
237237
if (((val) - (max)) > 0.00001) \
238-
(max) = (val); \
238+
(max) = (val); \
239239
else if (((min) - (val)) > 0.00001) { \
240240
(min) = (val); \
241241
} \
@@ -245,32 +245,32 @@ inline void func_mod_free(struct module *mod)
245245

246246
#define SET_MOD_STATISTICS(mod, member, i, type) \
247247
__SET_MOD_STATISTICS \
248-
( \
249-
mod##_tmp_s.mod##_##type.member, \
250-
mod##_statis[MEAN].mod##_##type.member, \
251-
mod##_statis[MAX].mod##_##type.member, \
252-
mod##_statis[MIN].mod##_##type.member, \
253-
i)
248+
( \
249+
mod##_tmp_s.mod##_##type.member, \
250+
mod##_statis[MEAN].mod##_##type.member, \
251+
mod##_statis[MAX].mod##_##type.member, \
252+
mod##_statis[MIN].mod##_##type.member, \
253+
i)
254254

255255
#define __PRINT_AVG(buf, pos, val, member, idx, count, otype) do \
256-
{ \
257-
if ((idx) == MEAN) \
258-
val[(idx)].member = \
259-
val[(idx)].member / (count); \
260-
PRINT(buf[(idx)] + pos[(idx)], \
261-
val[(idx)].member, \
262-
pos[(idx)], (otype)); \
263-
}while(0)
256+
{ \
257+
if ((idx) == MEAN) \
258+
val[(idx)].member = \
259+
val[(idx)].member / (count); \
260+
PRINT(buf[(idx)] + pos[(idx)], \
261+
val[(idx)].member, \
262+
pos[(idx)], (otype)); \
263+
}while(0)
264264

265265
#define __PRINT_AVG_SEP(buf, pos, val, member, sep, idx, count, otype) do \
266-
{ \
267-
if((idx) == MEAN) \
268-
val[(idx)].member = \
269-
(val[(idx)].member / (count)); \
270-
PRINT(buf[(idx)] + pos[(idx)], \
271-
val[(idx)].member * (sep), \
272-
pos[(idx)], (otype)); \
273-
}while(0)
266+
{ \
267+
if((idx) == MEAN) \
268+
val[(idx)].member = \
269+
(val[(idx)].member / (count)); \
270+
PRINT(buf[(idx)] + pos[(idx)], \
271+
val[(idx)].member * (sep), \
272+
pos[(idx)], (otype)); \
273+
}while(0)
274274

275275
inline char *getitem(char *r, char *mnt)
276276
{

0 commit comments

Comments
 (0)