We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9f15769 + 4832a96 commit 685c41aCopy full SHA for 685c41a
src/st-util/gdb-server.c
@@ -118,7 +118,7 @@ int32_t parse_options(int32_t argc, char** argv, st_state_t *st) {
118
{"no-reset", optional_argument, NULL, 'n'},
119
{"hot-plug", optional_argument, NULL, 'n'},
120
{"connect-under-reset", optional_argument, NULL, 'u'},
121
- {"freq", optional_argument, NULL, 'F'},
+ {"freq", required_argument, NULL, 'F'},
122
{"version", no_argument, NULL, 'V'},
123
{"semihosting", no_argument, NULL, SEMIHOSTING_OPTION},
124
{"serial", required_argument, NULL, SERIAL_OPTION},
@@ -152,11 +152,11 @@ int32_t parse_options(int32_t argc, char** argv, st_state_t *st) {
152
;
153
154
155
- int32_t option_index = 0;
+ int option_index = 0;
156
int32_t c;
157
int32_t q;
158
159
- while ((c = getopt_long(argc, argv, "hv::p:mnu", long_options, &option_index)) != -1)
+ while ((c = getopt_long(argc, argv, "hv::p:mnuF:V", long_options, &option_index)) != -1)
160
switch (c) {
161
case 0:
162
break;
src/stlink-lib/helper.c
@@ -23,14 +23,18 @@ uint32_t time_ms() {
23
}
24
25
int32_t arg_parse_freq(const char *str) {
26
- char *tail;
27
- int32_t value = (int32_t) strtol(str, &tail, 10);
28
-
29
- if (tail[0] == 'M' && tail[1] == '\0') {
30
- value = value*1000;
31
- } else if ((tail[0] != 'k' || tail[1] != '\0') && tail[0] != '\0') {
32
- return -1;
33
- }
34
35
- return value;
+ int32_t value = -1;
+ if (str != NULL) {
+ char* tail = NULL;
+ value = strtol(str, &tail, 10);
+ if (tail != NULL) {
+ if (tail[0] == 'M' && tail[1] == '\0') {
+ value = value*1000;
+ }
+ else if (tail[0] != '\0' && !(tail[0] == 'k' && tail[1] == '\0')) {
+ value = -1; /* error */
36
37
38
39
+ return value; /* frequency in kHz */
40
0 commit comments