Skip to content

Commit bbfcfa1

Browse files
committedMar 25, 2024
fix(upload_reset): remove warnings raised at build time
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent b2fdadd commit bbfcfa1

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed
 

‎src/upload_reset/unix/upload_reset.c

+38-35
Original file line numberDiff line numberDiff line change
@@ -118,44 +118,47 @@ int setDTR(unsigned short level)
118118
* Maple and Maple mini boards
119119
*/
120120

121-
main(int argc, char *argv[])
121+
int main(int argc, char *argv[])
122122
{
123-
123+
int ret = 0;
124124
if (argc<2 || argc >3)
125125
{
126126
printf("Usage upload-reset <serial_device> <Optional_delay_in_milliseconds>\n\r");
127-
return;
128-
}
129-
130-
if (openserial(argv[1]))
131-
{
132-
// Send magic sequence of DTR and RTS followed by the magic word "1EAF"
133-
setRTS(false);
134-
setDTR(false);
135-
setDTR(true);
136-
137-
usleep(50000L);
138-
139-
setDTR(false);
140-
setRTS(true);
141-
setDTR(true);
142-
143-
usleep(50000L);
144-
145-
setDTR(false);
146-
147-
usleep(50000L);
148-
149-
write(fd,"1EAF",4);
150-
151-
closeserial();
152-
if (argc==3)
153-
{
154-
usleep(atol(argv[2])*1000L);
155-
}
156-
}
157-
else
158-
{
159-
printf("Failed to open serial device.\n\r");
127+
ret = 1;
160128
}
129+
else {
130+
if (openserial(argv[1]))
131+
{
132+
// Send magic sequence of DTR and RTS followed by the magic word "1EAF"
133+
setRTS(false);
134+
setDTR(false);
135+
setDTR(true);
136+
137+
usleep(50000L);
138+
139+
setDTR(false);
140+
setRTS(true);
141+
setDTR(true);
142+
143+
usleep(50000L);
144+
145+
setDTR(false);
146+
147+
usleep(50000L);
148+
149+
write(fd,"1EAF",4);
150+
151+
closeserial();
152+
if (argc==3)
153+
{
154+
usleep(atol(argv[2])*1000L);
155+
}
156+
}
157+
else
158+
{
159+
printf("Failed to open serial device.\n\r");
160+
ret = 2;
161+
}
162+
}
163+
return ret;
161164
}

0 commit comments

Comments
 (0)
Failed to load comments.