1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

bootctl: modernization

Use strjoina to avoid error handling, and openat to simplify things.

Some fixes on the way:
- ferror does not set errno, so the return value was wrong in some cases
- errors are propagated in more cases
- EFI/systemd was created, but EFI/systemd-boot was deleted
- something is always printed on error
- when checking the version, comparison was done against "systemd-bo" for some reason
- return value was converted from negative to EXIT_SUCCESS/EXIT_FAILURE twice,
  resulting in EXIT_SUCCESS all the time
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2015-03-17 22:29:31 -04:00
parent 7f4e6a1ceb
commit d3226d7796
3 changed files with 305 additions and 561 deletions

File diff suppressed because it is too large Load Diff

View File

@ -148,6 +148,27 @@ char* endswith(const char *s, const char *postfix) {
return (char*) s + sl - pl;
}
char* endswith_no_case(const char *s, const char *postfix) {
size_t sl, pl;
assert(s);
assert(postfix);
sl = strlen(s);
pl = strlen(postfix);
if (pl == 0)
return (char*) s + sl;
if (sl < pl)
return NULL;
if (strcasecmp(s + sl - pl, postfix) != 0)
return NULL;
return (char*) s + sl - pl;
}
char* first_word(const char *s, const char *word) {
size_t sl, wl;
const char *p;

View File

@ -134,6 +134,7 @@ static inline char *startswith_no_case(const char *s, const char *prefix) {
}
char *endswith(const char *s, const char *postfix) _pure_;
char *endswith_no_case(const char *s, const char *postfix) _pure_;
char *first_word(const char *s, const char *word) _pure_;