chore: reduce debt for args
This commit is contained in:
+4
-4
@@ -71,17 +71,17 @@ static void print_help(int status_code) {
|
|||||||
exit(status_code);
|
exit(status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void invalid_arg(char *arg) {
|
static void invalid_arg(const char *arg) {
|
||||||
log_error("invalid argument: '%s'", arg);
|
log_error("invalid argument: '%s'", arg);
|
||||||
print_help(EXIT_FAILURE);
|
print_help(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void invalid_value(char *arg, char *value) {
|
static void invalid_value(const char *arg, const char *value) {
|
||||||
log_error("invalid value for argument '%s': '%s'", arg, value);
|
log_error("invalid value for argument '%s': '%s'", arg, value);
|
||||||
print_help(EXIT_FAILURE);
|
print_help(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_arg(char *arg, const char *ref) {
|
static bool is_arg(const char *arg, const char *ref) {
|
||||||
return strcoll(arg, ref) == 0;
|
return strcoll(arg, ref) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ static char *split_arg_value(char *arg) {
|
|||||||
return rest;
|
return rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int parse_uint(char *arg, char *value) {
|
static unsigned int parse_uint(const char *arg, const char *value) {
|
||||||
unsigned long long tmp_value;
|
unsigned long long tmp_value;
|
||||||
|
|
||||||
if (!string_is_number(value)) {
|
if (!string_is_number(value)) {
|
||||||
|
|||||||
+3
-3
@@ -39,7 +39,7 @@ unsigned int string_trim(char *str) {
|
|||||||
|
|
||||||
static bool is_digit(char c) { return c >= '0' && c <= '9'; }
|
static bool is_digit(char c) { return c >= '0' && c <= '9'; }
|
||||||
|
|
||||||
bool string_is_number(char *value) {
|
bool string_is_number(const char *value) {
|
||||||
unsigned long value_len;
|
unsigned long value_len;
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
@@ -57,8 +57,8 @@ bool string_is_number(char *value) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *string_replace_at(char *src, unsigned int from, unsigned int to,
|
char *string_replace_at(const char *src, unsigned int from, unsigned int to,
|
||||||
char *rpl) {
|
const char *rpl) {
|
||||||
unsigned long src_len, rpl_len;
|
unsigned long src_len, rpl_len;
|
||||||
char *dst;
|
char *dst;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
unsigned int string_trim(char *str);
|
unsigned int string_trim(char *str);
|
||||||
|
|
||||||
bool string_is_number(char *value);
|
bool string_is_number(const char *value);
|
||||||
|
|
||||||
char *string_replace_at(char *src, unsigned int from, unsigned int to,
|
char *string_replace_at(const char *src, unsigned int from, unsigned int to,
|
||||||
char *rpl);
|
const char *rpl);
|
||||||
|
|
||||||
#endif /* STRINGS_H */
|
#endif /* STRINGS_H */
|
||||||
Reference in New Issue
Block a user