Skip to content

Commit 4bcffe4

Browse files
committedJun 30, 2012
Fixed compiler warning about state variable that might not be initialized. Replaced tabs by spaces.
1 parent 791359c commit 4bcffe4

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed
 

‎limit_switches.c

+31-31
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,30 @@ int limsw_max( axis_e axis)
3434
{
3535
int active_state = !config_max_limit_switch_is_active_low( axis);
3636
switch (axis) {
37-
case x_axis: return (x_max_state == active_state);
38-
case y_axis: return (y_max_state == active_state);
39-
case z_axis: return (z_max_state == active_state);
40-
default: return 0;
37+
case x_axis: return (x_max_state == active_state);
38+
case y_axis: return (y_max_state == active_state);
39+
case z_axis: return (z_max_state == active_state);
40+
default: return 0;
4141
}
4242
}
4343

4444
int limsw_min( axis_e axis)
4545
{
4646
int active_state = !config_min_limit_switch_is_active_low( axis);
4747
switch (axis) {
48-
case x_axis: return (x_min_state == active_state);
49-
case y_axis: return (y_min_state == active_state);
50-
case z_axis: return (z_min_state == active_state);
51-
default: return 0;
48+
case x_axis: return (x_min_state == active_state);
49+
case y_axis: return (y_min_state == active_state);
50+
case z_axis: return (z_min_state == active_state);
51+
default: return 0;
5252
}
5353
}
5454

5555
typedef struct {
56-
int gpio_pin_nr;
57-
int active_low;
58-
int in_use;
59-
void (*alarm_call_back)( int state);
60-
int fd;
56+
int gpio_pin_nr;
57+
int active_low;
58+
int in_use;
59+
void (*alarm_call_back)( int state);
60+
int fd;
6161
} limit_switch_struct;
6262

6363
/****************************************************************
@@ -112,7 +112,7 @@ static void* limsw_watcher( void* arg)
112112
}
113113

114114
while (1) {
115-
const int timeout = -1; /* no timeout */
115+
const int timeout = -1; /* no timeout */
116116

117117
int rc = poll( *fdset, nr_limits, timeout);
118118
if (rc < 0) {
@@ -129,26 +129,26 @@ static void* limsw_watcher( void* arg)
129129
}
130130
for (i = 0 ; i < nr_limits ; ++i) {
131131
if ((*fdset)[ i].revents & POLLPRI) {
132-
int state;
133-
len = read( (*fdset)[ i].fd, buf, sizeof( buf));
134-
if (len == 2 && (buf[ 0] == '0' || buf[ 0] == '1')) {
135-
// Get initial state info
136-
state = buf[ 0] - '0';
132+
int state = 0;
133+
len = read( (*fdset)[ i].fd, buf, sizeof( buf));
134+
if (len == 2 && (buf[ 0] == '0' || buf[ 0] == '1')) {
135+
// Get initial state info
136+
state = buf[ 0] - '0';
137137
if (debug_flags & DEBUG_LIMSW) {
138138
printf( "*** GPIO %2d event, state %d ***\n", gpio[ i], state);
139139
}
140-
} else {
141-
fprintf( stderr, "\n*** GPIO %2d unexpected event, BUG??? ***\n", gpio[ i]);
142-
}
143-
switch (gpio[ i]) {
144-
case XMIN_GPIO: x_min_state = state; break;
145-
case XMAX_GPIO: x_max_state = state; break;
146-
case YMIN_GPIO: y_min_state = state; break;
147-
case YMAX_GPIO: y_max_state = state; break;
148-
case ZMIN_GPIO: z_min_state = state; break;
149-
case ZMAX_GPIO: z_max_state = state; break;
150-
}
151-
lseek( (*fdset)[ i].fd, 0, SEEK_SET);
140+
} else {
141+
fprintf( stderr, "\n*** GPIO %2d unexpected event, BUG??? ***\n", gpio[ i]);
142+
}
143+
switch (gpio[ i]) {
144+
case XMIN_GPIO: x_min_state = state; break;
145+
case XMAX_GPIO: x_max_state = state; break;
146+
case YMIN_GPIO: y_min_state = state; break;
147+
case YMAX_GPIO: y_max_state = state; break;
148+
case ZMIN_GPIO: z_min_state = state; break;
149+
case ZMAX_GPIO: z_max_state = state; break;
150+
}
151+
lseek( (*fdset)[ i].fd, 0, SEEK_SET);
152152
}
153153
}
154154
}

0 commit comments

Comments
 (0)
Please sign in to comment.