mirror of
https://github.com/javalsai/lidm.git
synced 2025-08-30 09:58:00 +02:00
fix: satify all clang code requirements
This commit is contained in:
4
Makefile
4
Makefile
@@ -138,8 +138,8 @@ pre-commit:
|
||||
prettier -c "**/*.md"
|
||||
git ls-files "*.sh" "*/PKGBUILD" | xargs shellcheck --shell=bash
|
||||
clang-format -i $$(git ls-files "*.c" "*.h")
|
||||
git ls-files -z "*.h" | \
|
||||
parallel -j$$(nproc) -q0 --no-notice --will-cite --tty clang-tidy --quiet |& \
|
||||
git ls-files -z "*.c" "*.h" | \
|
||||
parallel -j$$(nproc) -q0 --no-notice --will-cite --tty clang-tidy -warnings-as-errors=\* --quiet |& \
|
||||
grep -v "warnings generated." || true
|
||||
|
||||
print-version:
|
||||
|
@@ -17,17 +17,17 @@
|
||||
struct pamh_getenv_status {
|
||||
char error_flag;
|
||||
union {
|
||||
char** envlist;
|
||||
const char* errfn;
|
||||
char* NULLABLE* NNULLABLE envlist;
|
||||
const char* NNULLABLE errfn;
|
||||
};
|
||||
};
|
||||
|
||||
// Doesn't include `source`s
|
||||
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
|
||||
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* NNULLABLE handle,
|
||||
struct passwd* NNULLABLE pw,
|
||||
enum SessionType session_typ);
|
||||
|
||||
void free_envlist(char** NNULLABLE envlist);
|
||||
void free_envlist(char* NULLABLE* NNULLABLE envlist);
|
||||
pam_handle_t* NULLABLE get_pamh(char* NNULLABLE user, char* NNULLABLE passwd);
|
||||
|
||||
#endif /* PAM_H */
|
||||
|
@@ -19,6 +19,7 @@ char* trim_str(char* str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
int read_desktop(FILE* fd, void* ctx,
|
||||
struct status (*cb)(void* ctx, char* table, char* key,
|
||||
char* value)) {
|
||||
|
31
src/pam.c
31
src/pam.c
@@ -76,24 +76,20 @@ char* NULLABLE xdg_ssession_type_str(enum SessionType typ) {
|
||||
return xdg_session_type;
|
||||
}
|
||||
|
||||
#define FAIL_ALLOC(status) \
|
||||
{ \
|
||||
(status).error_flag = PAMH_ERR_ALLOC; \
|
||||
return (status); \
|
||||
#define FAIL_ALLOC() \
|
||||
{ \
|
||||
return (struct pamh_getenv_status){.error_flag = PAMH_ERR_ALLOC}; \
|
||||
}
|
||||
#define FAIL(status, ERR, ERRFN) \
|
||||
{ \
|
||||
(status).error_flag = (ERR); \
|
||||
(status).errfn = (ERRFN); \
|
||||
return (status); \
|
||||
#define FAIL(ERR, ERRFN) \
|
||||
{ \
|
||||
return (struct pamh_getenv_status){.error_flag = (ERR), .errfn = (ERRFN)}; \
|
||||
}
|
||||
|
||||
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
|
||||
struct passwd* NNULLABLE pw,
|
||||
enum SessionType session_typ) {
|
||||
struct pamh_getenv_status status;
|
||||
char** envlist = pam_getenvlist(handle);
|
||||
if (!envlist) FAIL(status, PAMH_ERR_ERRNO, "pam_getenvlist");
|
||||
char** raw_envlist = pam_getenvlist(handle);
|
||||
if (!raw_envlist) FAIL(PAMH_ERR_ERRNO, "pam_getenvlist");
|
||||
|
||||
struct envpair extra_env[] = {
|
||||
{"TERM", getenv("TERM")},
|
||||
@@ -104,11 +100,12 @@ struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
|
||||
{"LOGNAME", pw->pw_name},
|
||||
{"XDG_SESSION_TYPE", xdg_ssession_type_str(session_typ)}};
|
||||
|
||||
status.error_flag = PAMH_ERR_NOERR;
|
||||
status.envlist = merge_envlist(envlist, extra_env, LEN(extra_env));
|
||||
if (!status.envlist) FAIL_ALLOC(status);
|
||||
|
||||
return status;
|
||||
char** envlist = merge_envlist(raw_envlist, extra_env, LEN(extra_env));
|
||||
if (!envlist) FAIL_ALLOC();
|
||||
return (struct pamh_getenv_status){
|
||||
.error_flag = PAMH_ERR_NOERR,
|
||||
.envlist = envlist,
|
||||
};
|
||||
}
|
||||
|
||||
#undef FAIL
|
||||
|
@@ -118,6 +118,7 @@ static int fn(const char* fpath, const struct stat* sb, int typeflag) {
|
||||
int parse_status = parse_exec_string(ctx.exec, &arg_count, &args);
|
||||
if (parse_status != 0 || arg_count == 0 || !args[0]) {
|
||||
log_printf("[E] parsing exec string '%s': %d\n", ctx.exec, parse_status);
|
||||
free(this_session);
|
||||
goto err_parsing;
|
||||
}
|
||||
free(ctx.exec);
|
||||
|
Reference in New Issue
Block a user