Skip to content

Commit 0702e66

Browse files
jeplerpetterreinholdtsen
authored andcommitted
halcmd: use SHMFIELD() for next-pointers
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
1 parent 6803de1 commit 0702e66

1 file changed

Lines changed: 42 additions & 29 deletions

File tree

src/hal/utils/halcmd_commands.c

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int preflight_net_cmd(char *signal, hal_sig_t *sig, char *pins[]) {
396396
if(writers || bidirs)
397397
{
398398
hal_pin_t *pin;
399-
int next;
399+
SHMFIELD(hal_pin_t) next;
400400
for(next = hal_data->pin_list_ptr; next; next=pin->next_ptr)
401401
{
402402
pin = SHMPTR(next);
@@ -1199,7 +1199,8 @@ int do_loadrt_cmd(char *mod_name, char *args[])
11991199

12001200
int do_delsig_cmd(char *mod_name)
12011201
{
1202-
int next, retval, retval1, n;
1202+
SHMFIELD(hal_sig_t) next;
1203+
int retval, retval1, n;
12031204
hal_sig_t *sig;
12041205
char sigs[MAX_EXPECTED_SIGS][HAL_NAME_LEN+1];
12051206

@@ -1261,7 +1262,8 @@ int do_delsig_cmd(char *mod_name)
12611262

12621263
int do_unloadusr_cmd(char *mod_name)
12631264
{
1264-
int next, all;
1265+
SHMFIELD(hal_comp_t) next;
1266+
int all;
12651267
hal_comp_t *comp;
12661268
pid_t ourpid = getpid();
12671269

@@ -1292,7 +1294,8 @@ int do_unloadusr_cmd(char *mod_name)
12921294

12931295
int do_unloadrt_cmd(char *mod_name)
12941296
{
1295-
int next, retval, retval1, n, all;
1297+
SHMFIELD(hal_comp_t) next;
1298+
int retval, retval1, n, all;
12961299
hal_comp_t *comp;
12971300
char comps[64][HAL_NAME_LEN+1];
12981301

@@ -1632,7 +1635,7 @@ int do_waitusr_cmd(char *comp_name)
16321635

16331636
static void print_comp_info(char **patterns)
16341637
{
1635-
int next;
1638+
SHMFIELD(hal_comp_t) next;
16361639
hal_comp_t *comp;
16371640

16381641
if (scriptmode == 0) {
@@ -1671,7 +1674,7 @@ static void print_comp_info(char **patterns)
16711674

16721675
static void print_pin_info(int type, char **patterns)
16731676
{
1674-
int next;
1677+
SHMFIELD(hal_pin_t) next;
16751678
hal_pin_t *pin;
16761679
hal_comp_t *comp;
16771680
hal_sig_t *sig;
@@ -1723,7 +1726,7 @@ static void print_pin_info(int type, char **patterns)
17231726

17241727
static void print_pin_aliases(char **patterns)
17251728
{
1726-
int next;
1729+
SHMFIELD(hal_pin_t) next;
17271730
hal_oldname_t *oldname;
17281731
hal_pin_t *pin;
17291732

@@ -1754,7 +1757,7 @@ static void print_pin_aliases(char **patterns)
17541757

17551758
static void print_sig_info(int type, char **patterns)
17561759
{
1757-
int next;
1760+
SHMFIELD(hal_sig_t) next;
17581761
hal_sig_t *sig;
17591762
void *dptr;
17601763
hal_pin_t *pin;
@@ -1789,7 +1792,7 @@ static void print_sig_info(int type, char **patterns)
17891792

17901793
static void print_script_sig_info(int type, char **patterns)
17911794
{
1792-
int next;
1795+
SHMFIELD(hal_sig_t) next;
17931796
hal_sig_t *sig;
17941797
void *dptr;
17951798
hal_pin_t *pin;
@@ -1822,7 +1825,7 @@ static void print_script_sig_info(int type, char **patterns)
18221825

18231826
static void print_param_info(int type, char **patterns)
18241827
{
1825-
int next;
1828+
SHMFIELD(hal_param_t) next;
18261829
hal_param_t *param;
18271830
hal_comp_t *comp;
18281831

@@ -1858,7 +1861,7 @@ static void print_param_info(int type, char **patterns)
18581861

18591862
static void print_param_aliases(char **patterns)
18601863
{
1861-
int next;
1864+
SHMFIELD(hal_param_t) next;
18621865
hal_oldname_t *oldname;
18631866
hal_param_t *param;
18641867

@@ -1889,7 +1892,7 @@ static void print_param_aliases(char **patterns)
18891892

18901893
static void print_funct_info(char **patterns)
18911894
{
1892-
int next;
1895+
SHMFIELD(hal_funct_t) next;
18931896
hal_funct_t *fptr;
18941897
hal_comp_t *comp;
18951898

@@ -1925,7 +1928,8 @@ static void print_funct_info(char **patterns)
19251928

19261929
static void print_thread_info(char **patterns)
19271930
{
1928-
int next_thread, n;
1931+
SHMFIELD(hal_thread_t) next_thread;
1932+
int n;
19291933
hal_thread_t *tptr;
19301934
hal_list_t *list_root, *list_entry;
19311935
hal_funct_entry_t *fentry;
@@ -2005,7 +2009,7 @@ static void print_thread_info(char **patterns)
20052009

20062010
static void print_comp_names(char **patterns)
20072011
{
2008-
int next;
2012+
SHMFIELD(hal_comp_t) next;
20092013
hal_comp_t *comp;
20102014

20112015
rtapi_mutex_get(&(hal_data->mutex));
@@ -2023,7 +2027,7 @@ static void print_comp_names(char **patterns)
20232027

20242028
static void print_pin_names(char **patterns)
20252029
{
2026-
int next;
2030+
SHMFIELD(hal_pin_t) next;
20272031
hal_pin_t *pin;
20282032

20292033
rtapi_mutex_get(&(hal_data->mutex));
@@ -2041,7 +2045,7 @@ static void print_pin_names(char **patterns)
20412045

20422046
static void print_sig_names(char **patterns)
20432047
{
2044-
int next;
2048+
SHMFIELD(hal_sig_t) next;
20452049
hal_sig_t *sig;
20462050

20472051
rtapi_mutex_get(&(hal_data->mutex));
@@ -2059,7 +2063,7 @@ static void print_sig_names(char **patterns)
20592063

20602064
static void print_param_names(char **patterns)
20612065
{
2062-
int next;
2066+
SHMFIELD(hal_param_t) next;
20632067
hal_param_t *param;
20642068

20652069
rtapi_mutex_get(&(hal_data->mutex));
@@ -2077,7 +2081,7 @@ static void print_param_names(char **patterns)
20772081

20782082
static void print_funct_names(char **patterns)
20792083
{
2080-
int next;
2084+
SHMFIELD(hal_funct_t) next;
20812085
hal_funct_t *fptr;
20822086

20832087
rtapi_mutex_get(&(hal_data->mutex));
@@ -2095,7 +2099,7 @@ static void print_funct_names(char **patterns)
20952099

20962100
static void print_thread_names(char **patterns)
20972101
{
2098-
int next_thread;
2102+
SHMFIELD(hal_thread_t) next_thread;
20992103
hal_thread_t *tptr;
21002104

21012105
rtapi_mutex_get(&(hal_data->mutex));
@@ -2149,7 +2153,7 @@ static int count_list(int list_root)
21492153

21502154
static void print_mem_status()
21512155
{
2152-
int active, recycled, next;
2156+
int active, recycled;
21532157
hal_pin_t *pin;
21542158
hal_param_t *param;
21552159

@@ -2169,19 +2173,23 @@ static void print_mem_status()
21692173
halcmd_output(" active/recycled parameters: %d/%d\n", active, recycled);
21702174
// count aliases
21712175
rtapi_mutex_get(&(hal_data->mutex));
2172-
next = hal_data->pin_list_ptr;
2176+
{
2177+
SHMFIELD(hal_pin_t) next = hal_data->pin_list_ptr;
21732178
active = 0;
21742179
while (next != 0) {
21752180
pin = SHMPTR(next);
21762181
if ( pin->oldname != 0 ) active++;
21772182
next = pin->next_ptr;
21782183
}
2179-
next = hal_data->param_list_ptr;
2184+
}
2185+
{
2186+
SHMFIELD(hal_param_t) next = hal_data->param_list_ptr;
21802187
while (next != 0) {
21812188
param = SHMPTR(next);
21822189
if ( param->oldname != 0 ) active++;
21832190
next = param->next_ptr;
21842191
}
2192+
}
21852193
rtapi_mutex_give(&(hal_data->mutex));
21862194
recycled = count_list(hal_data->oldname_free_ptr);
21872195
halcmd_output(" active/recycled aliases: %d/%d\n", active, recycled);
@@ -2489,7 +2497,7 @@ int do_save_cmd(const char *type, char *filename)
24892497

24902498
static void save_comps(FILE *dst)
24912499
{
2492-
int next;
2500+
SHMFIELD(hal_comp_t) next;
24932501
hal_comp_t *comp;
24942502

24952503
fprintf(dst, "# components\n");
@@ -2543,13 +2551,14 @@ static void save_comps(FILE *dst)
25432551

25442552
static void save_aliases(FILE *dst)
25452553
{
2546-
int next;
25472554
hal_pin_t *pin;
25482555
hal_param_t *param;
25492556
hal_oldname_t *oldname;
25502557

25512558
fprintf(dst, "# pin aliases\n");
25522559
rtapi_mutex_get(&(hal_data->mutex));
2560+
{
2561+
SHMFIELD(hal_pin_t) next;
25532562
next = hal_data->pin_list_ptr;
25542563
while (next != 0) {
25552564
pin = SHMPTR(next);
@@ -2560,7 +2569,10 @@ static void save_aliases(FILE *dst)
25602569
}
25612570
next = pin->next_ptr;
25622571
}
2572+
}
25632573
fprintf(dst, "# param aliases\n");
2574+
{
2575+
SHMFIELD(hal_param_t) next;
25642576
next = hal_data->param_list_ptr;
25652577
while (next != 0) {
25662578
param = SHMPTR(next);
@@ -2571,12 +2583,13 @@ static void save_aliases(FILE *dst)
25712583
}
25722584
next = param->next_ptr;
25732585
}
2586+
}
25742587
rtapi_mutex_give(&(hal_data->mutex));
25752588
}
25762589

25772590
static void save_signals(FILE *dst, int only_unlinked)
25782591
{
2579-
int next;
2592+
SHMFIELD(hal_sig_t) next;
25802593
hal_sig_t *sig;
25812594

25822595
fprintf(dst, "# signals\n");
@@ -2592,7 +2605,7 @@ static void save_signals(FILE *dst, int only_unlinked)
25922605

25932606
static void save_links(FILE *dst, int arrow)
25942607
{
2595-
int next;
2608+
SHMFIELD(hal_pin_t) next;
25962609
hal_pin_t *pin;
25972610
hal_sig_t *sig;
25982611
const char *arrow_str;
@@ -2618,7 +2631,7 @@ static void save_links(FILE *dst, int arrow)
26182631

26192632
static void save_nets(FILE *dst, int arrow)
26202633
{
2621-
int next;
2634+
SHMFIELD(hal_sig_t) next;
26222635
hal_pin_t *pin;
26232636
hal_sig_t *sig;
26242637
const char *arrow_str;
@@ -2701,7 +2714,7 @@ static void save_nets(FILE *dst, int arrow)
27012714

27022715
static void save_params(FILE *dst)
27032716
{
2704-
int next;
2717+
SHMFIELD(hal_param_t) next;
27052718
hal_param_t *param;
27062719

27072720
fprintf(dst, "# parameter values\n");
@@ -2721,7 +2734,7 @@ static void save_params(FILE *dst)
27212734

27222735
static void save_threads(FILE *dst)
27232736
{
2724-
int next_thread;
2737+
SHMFIELD(hal_thread_t) next_thread;
27252738
hal_thread_t *tptr;
27262739
hal_list_t *list_root, *list_entry;
27272740
hal_funct_entry_t *fentry;

0 commit comments

Comments
 (0)