sd-journal: make prot_from_flags() static and rename

The function had just one caller and a name that didn't explain much.
Let's make it static and rename for clarity.

While at it, the only caller was not doing error handling correctly
— the function would potentially return a negative error value which
wasn't handled. In practice this couldn't happen, but let's remove
this ambiguity.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-11-08 13:41:13 +01:00
parent bcb639662e
commit 0e58dc999c
3 changed files with 14 additions and 21 deletions
-18
View File
@@ -23,24 +23,6 @@ int saved_argc = 0;
char **saved_argv = NULL;
static int saved_in_initrd = -1;
int prot_from_flags(int flags) {
switch (flags & O_ACCMODE) {
case O_RDONLY:
return PROT_READ;
case O_WRONLY:
return PROT_WRITE;
case O_RDWR:
return PROT_READ|PROT_WRITE;
default:
return -EINVAL;
}
}
bool in_initrd(void) {
int r;
const char *e;
-2
View File
@@ -19,8 +19,6 @@ static inline void save_argc_argv(int argc, char **argv) {
saved_argv = argv;
}
int prot_from_flags(int flags) _const_;
bool in_initrd(void);
void in_initrd_force(bool value);