Browse Source

style: use astyle for C formatting

master
Harald Hoyer 3 years ago committed by Harald Hoyer
parent
commit
f1ed92c348
  1. 32
      install/dracut-install.c
  2. 62
      install/hashmap.c
  3. 62
      install/hashmap.h
  4. 8
      install/macro.h
  5. 8
      install/strv.c
  6. 72
      install/util.c
  7. 62
      install/util.h
  8. 6
      logtee.c

32
install/dracut-install.c

@ -127,7 +127,7 @@ static inline void kmod_module_dependency_symbols_free_listp(struct kmod_list ** @@ -127,7 +127,7 @@ static inline void kmod_module_dependency_symbols_free_listp(struct kmod_list **

#define _cleanup_kmod_module_dependency_symbols_free_list_ _cleanup_(kmod_module_dependency_symbols_free_listp)

static inline void fts_closep(FTS ** p)
static inline void fts_closep(FTS **p)
{
if (*p)
fts_close(*p);
@ -286,8 +286,8 @@ static int cp(const char *src, const char *dst) @@ -286,8 +286,8 @@ static int cp(const char *src, const char *dst)
goto normal_copy;

dest_desc =
open(dst, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC,
(sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO));
open(dst, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC,
(sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO));

if (dest_desc < 0) {
goto normal_copy;
@ -320,7 +320,7 @@ static int cp(const char *src, const char *dst) @@ -320,7 +320,7 @@ static int cp(const char *src, const char *dst)
use_clone = false;
}

normal_copy:
normal_copy:
pid = fork();
if (pid == 0) {
if (geteuid() == 0 && no_xattr == false)
@ -337,12 +337,12 @@ static int cp(const char *src, const char *dst) @@ -337,12 +337,12 @@ static int cp(const char *src, const char *dst)
ret = -1;
if (geteuid() == 0 && no_xattr == false)
log_error
("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s",
src, dst);
("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s",
src, dst);
else
log_error
("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s",
src, dst);
("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s",
src, dst);
break;
}
}
@ -692,7 +692,7 @@ void dracut_log_cp(const char *path) @@ -692,7 +692,7 @@ void dracut_log_cp(const char *path)
log_error("Could not append '%s' to logfile '%s': %m", path, logfile);
}

static bool check_hashmap(Hashmap * hm, const char *item)
static bool check_hashmap(Hashmap *hm, const char *item)
{
char *existing;
existing = hashmap_get(hm, item);
@ -907,8 +907,8 @@ static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir @@ -907,8 +907,8 @@ static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir
_cleanup_free_ char *absdestpath = NULL;

ret =
asprintf(&absdestpath, "%s/%s", destrootdir,
(abspath[0] == '/' ? (abspath + 1) : abspath) + sysrootdirlen);
asprintf(&absdestpath, "%s/%s", destrootdir,
(abspath[0] == '/' ? (abspath + 1) : abspath) + sysrootdirlen);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
@ -1353,8 +1353,8 @@ static int install_all(int argc, char **argv) @@ -1353,8 +1353,8 @@ static int install_all(int argc, char **argv)
for (j = 0; j < globbuf.gl_pathc; j++) {
char *dest = strdup(globbuf.gl_pathv[j] + sysrootdirlen);
ret |=
dracut_install(globbuf.gl_pathv[j] + sysrootdirlen, dest,
arg_createdir, arg_resolvedeps, true);
dracut_install(globbuf.gl_pathv[j] + sysrootdirlen, dest,
arg_createdir, arg_resolvedeps, true);
free(dest);
}
}
@ -1638,7 +1638,7 @@ static int modalias_list(struct kmod_ctx *ctx) @@ -1638,7 +1638,7 @@ static int modalias_list(struct kmod_ctx *ctx)
char *paths[] = { "/sys/devices", NULL };
fts = fts_open(paths, FTS_NOCHDIR | FTS_NOSTAT, NULL);
}
for (FTSENT * ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) {
for (FTSENT *ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_kmod_module_unref_list_ struct kmod_list *list = NULL;
struct kmod_list *l;
@ -1856,7 +1856,7 @@ static int install_modules(int argc, char **argv) @@ -1856,7 +1856,7 @@ static int install_modules(int argc, char **argv)
fts = fts_open(paths, FTS_COMFOLLOW | FTS_NOCHDIR | FTS_NOSTAT | FTS_LOGICAL, NULL);
}

for (FTSENT * ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) {
for (FTSENT *ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) {
_cleanup_kmod_module_unref_list_ struct kmod_list *modlist = NULL;
_cleanup_free_ const char *modname = NULL;

@ -2118,7 +2118,7 @@ int main(int argc, char **argv) @@ -2118,7 +2118,7 @@ int main(int argc, char **argv)
if (arg_optional)
r = EXIT_SUCCESS;

finish:
finish:
if (logfile_f)
fclose(logfile_f);


62
install/hashmap.c

@ -94,7 +94,7 @@ Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) @@ -94,7 +94,7 @@ Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func)
return h;
}

int hashmap_ensure_allocated(Hashmap ** h, hash_func_t hash_func, compare_func_t compare_func)
int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func)
{
assert(h);

@ -107,7 +107,7 @@ int hashmap_ensure_allocated(Hashmap ** h, hash_func_t hash_func, compare_func_t @@ -107,7 +107,7 @@ int hashmap_ensure_allocated(Hashmap ** h, hash_func_t hash_func, compare_func_t
return 0;
}

static void link_entry(Hashmap * h, struct hashmap_entry *e, unsigned hash)
static void link_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash)
{
assert(h);
assert(e);
@ -135,7 +135,7 @@ static void link_entry(Hashmap * h, struct hashmap_entry *e, unsigned hash) @@ -135,7 +135,7 @@ static void link_entry(Hashmap * h, struct hashmap_entry *e, unsigned hash)
assert(h->n_entries >= 1);
}

static void unlink_entry(Hashmap * h, struct hashmap_entry *e, unsigned hash)
static void unlink_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash)
{
assert(h);
assert(e);
@ -164,7 +164,7 @@ static void unlink_entry(Hashmap * h, struct hashmap_entry *e, unsigned hash) @@ -164,7 +164,7 @@ static void unlink_entry(Hashmap * h, struct hashmap_entry *e, unsigned hash)
h->n_entries--;
}

static void remove_entry(Hashmap * h, struct hashmap_entry **ep)
static void remove_entry(Hashmap *h, struct hashmap_entry **ep)
{
struct hashmap_entry *e = *ep;
unsigned hash;
@ -180,7 +180,7 @@ static void remove_entry(Hashmap * h, struct hashmap_entry **ep) @@ -180,7 +180,7 @@ static void remove_entry(Hashmap * h, struct hashmap_entry **ep)
*ep = NULL;
}

void hashmap_free(Hashmap * h)
void hashmap_free(Hashmap *h)
{

if (!h)
@ -191,7 +191,7 @@ void hashmap_free(Hashmap * h) @@ -191,7 +191,7 @@ void hashmap_free(Hashmap * h)
free(h);
}

void hashmap_free_free(Hashmap * h)
void hashmap_free_free(Hashmap *h)
{
void *p;

@ -201,7 +201,7 @@ void hashmap_free_free(Hashmap * h) @@ -201,7 +201,7 @@ void hashmap_free_free(Hashmap * h)
hashmap_free(h);
}

void hashmap_clear(Hashmap * h)
void hashmap_clear(Hashmap *h)
{
if (!h)
return;
@ -212,7 +212,7 @@ void hashmap_clear(Hashmap * h) @@ -212,7 +212,7 @@ void hashmap_clear(Hashmap * h)
}
}

static struct hashmap_entry *hash_scan(Hashmap * h, unsigned hash, const void *key)
static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key)
{
struct hashmap_entry *e;
assert(h);
@ -225,7 +225,7 @@ static struct hashmap_entry *hash_scan(Hashmap * h, unsigned hash, const void *k @@ -225,7 +225,7 @@ static struct hashmap_entry *hash_scan(Hashmap * h, unsigned hash, const void *k
return NULL;
}

int hashmap_put(Hashmap * h, const void *key, void *value)
int hashmap_put(Hashmap *h, const void *key, void *value)
{
struct hashmap_entry *e;
unsigned hash;
@ -255,7 +255,7 @@ int hashmap_put(Hashmap * h, const void *key, void *value) @@ -255,7 +255,7 @@ int hashmap_put(Hashmap * h, const void *key, void *value)
return 1;
}

int hashmap_replace(Hashmap * h, const void *key, void *value)
int hashmap_replace(Hashmap *h, const void *key, void *value)
{
struct hashmap_entry *e;
unsigned hash;
@ -273,7 +273,7 @@ int hashmap_replace(Hashmap * h, const void *key, void *value) @@ -273,7 +273,7 @@ int hashmap_replace(Hashmap * h, const void *key, void *value)
return hashmap_put(h, key, value);
}

void *hashmap_get(Hashmap * h, const void *key)
void *hashmap_get(Hashmap *h, const void *key)
{
unsigned hash;
struct hashmap_entry *e;
@ -289,7 +289,7 @@ void *hashmap_get(Hashmap * h, const void *key) @@ -289,7 +289,7 @@ void *hashmap_get(Hashmap * h, const void *key)
return e->value;
}

void *hashmap_remove(Hashmap * h, const void *key)
void *hashmap_remove(Hashmap *h, const void *key)
{
struct hashmap_entry *e;
unsigned hash;
@ -309,7 +309,7 @@ void *hashmap_remove(Hashmap * h, const void *key) @@ -309,7 +309,7 @@ void *hashmap_remove(Hashmap * h, const void *key)
return data;
}

int hashmap_remove_and_put(Hashmap * h, const void *old_key, const void *new_key, void *value)
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value)
{
struct hashmap_entry *e;
unsigned old_hash, new_hash;
@ -335,7 +335,7 @@ int hashmap_remove_and_put(Hashmap * h, const void *old_key, const void *new_key @@ -335,7 +335,7 @@ int hashmap_remove_and_put(Hashmap * h, const void *old_key, const void *new_key
return 0;
}

int hashmap_remove_and_replace(Hashmap * h, const void *old_key, const void *new_key, void *value)
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value)
{
struct hashmap_entry *e, *k;
unsigned old_hash, new_hash;
@ -363,7 +363,7 @@ int hashmap_remove_and_replace(Hashmap * h, const void *old_key, const void *new @@ -363,7 +363,7 @@ int hashmap_remove_and_replace(Hashmap * h, const void *old_key, const void *new
return 0;
}

void *hashmap_remove_value(Hashmap * h, const void *key, void *value)
void *hashmap_remove_value(Hashmap *h, const void *key, void *value)
{
struct hashmap_entry *e;
unsigned hash;
@ -384,7 +384,7 @@ void *hashmap_remove_value(Hashmap * h, const void *key, void *value) @@ -384,7 +384,7 @@ void *hashmap_remove_value(Hashmap * h, const void *key, void *value)
return value;
}

void *hashmap_iterate(Hashmap * h, Iterator * i, const void **key)
void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key)
{
struct hashmap_entry *e;

@ -411,7 +411,7 @@ void *hashmap_iterate(Hashmap * h, Iterator * i, const void **key) @@ -411,7 +411,7 @@ void *hashmap_iterate(Hashmap * h, Iterator * i, const void **key)

return e->value;

at_end:
at_end:
*i = ITERATOR_LAST;

if (key)
@ -420,7 +420,7 @@ void *hashmap_iterate(Hashmap * h, Iterator * i, const void **key) @@ -420,7 +420,7 @@ void *hashmap_iterate(Hashmap * h, Iterator * i, const void **key)
return NULL;
}

void *hashmap_iterate_backwards(Hashmap * h, Iterator * i, const void **key)
void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key)
{
struct hashmap_entry *e;

@ -447,7 +447,7 @@ void *hashmap_iterate_backwards(Hashmap * h, Iterator * i, const void **key) @@ -447,7 +447,7 @@ void *hashmap_iterate_backwards(Hashmap * h, Iterator * i, const void **key)

return e->value;

at_beginning:
at_beginning:
*i = ITERATOR_FIRST;

if (key)
@ -456,7 +456,7 @@ void *hashmap_iterate_backwards(Hashmap * h, Iterator * i, const void **key) @@ -456,7 +456,7 @@ void *hashmap_iterate_backwards(Hashmap * h, Iterator * i, const void **key)
return NULL;
}

void *hashmap_iterate_skip(Hashmap * h, const void *key, Iterator * i)
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i)
{
unsigned hash;
struct hashmap_entry *e;
@ -474,7 +474,7 @@ void *hashmap_iterate_skip(Hashmap * h, const void *key, Iterator * i) @@ -474,7 +474,7 @@ void *hashmap_iterate_skip(Hashmap * h, const void *key, Iterator * i)
return e->value;
}

void *hashmap_first(Hashmap * h)
void *hashmap_first(Hashmap *h)
{

if (!h)
@ -486,7 +486,7 @@ void *hashmap_first(Hashmap * h) @@ -486,7 +486,7 @@ void *hashmap_first(Hashmap * h)
return h->iterate_list_head->value;
}

void *hashmap_first_key(Hashmap * h)
void *hashmap_first_key(Hashmap *h)
{

if (!h)
@ -498,7 +498,7 @@ void *hashmap_first_key(Hashmap * h) @@ -498,7 +498,7 @@ void *hashmap_first_key(Hashmap * h)
return (void *)h->iterate_list_head->key;
}

void *hashmap_last(Hashmap * h)
void *hashmap_last(Hashmap *h)
{

if (!h)
@ -510,7 +510,7 @@ void *hashmap_last(Hashmap * h) @@ -510,7 +510,7 @@ void *hashmap_last(Hashmap * h)
return h->iterate_list_tail->value;
}

void *hashmap_steal_first(Hashmap * h)
void *hashmap_steal_first(Hashmap *h)
{
struct hashmap_entry *e;
void *data;
@ -528,7 +528,7 @@ void *hashmap_steal_first(Hashmap * h) @@ -528,7 +528,7 @@ void *hashmap_steal_first(Hashmap * h)
return data;
}

void *hashmap_steal_first_key(Hashmap * h)
void *hashmap_steal_first_key(Hashmap *h)
{
struct hashmap_entry *e;
void *key;
@ -546,7 +546,7 @@ void *hashmap_steal_first_key(Hashmap * h) @@ -546,7 +546,7 @@ void *hashmap_steal_first_key(Hashmap * h)
return key;
}

unsigned hashmap_size(Hashmap * h)
unsigned hashmap_size(Hashmap *h)
{

if (!h)
@ -555,7 +555,7 @@ unsigned hashmap_size(Hashmap * h) @@ -555,7 +555,7 @@ unsigned hashmap_size(Hashmap * h)
return h->n_entries;
}

bool hashmap_isempty(Hashmap * h)
bool hashmap_isempty(Hashmap *h)
{

if (!h)
@ -564,7 +564,7 @@ bool hashmap_isempty(Hashmap * h) @@ -564,7 +564,7 @@ bool hashmap_isempty(Hashmap * h)
return h->n_entries == 0;
}

int hashmap_merge(Hashmap * h, Hashmap * other)
int hashmap_merge(Hashmap *h, Hashmap *other)
{
struct hashmap_entry *e;

@ -584,7 +584,7 @@ int hashmap_merge(Hashmap * h, Hashmap * other) @@ -584,7 +584,7 @@ int hashmap_merge(Hashmap * h, Hashmap * other)
return 0;
}

void hashmap_move(Hashmap * h, Hashmap * other)
void hashmap_move(Hashmap *h, Hashmap *other)
{
struct hashmap_entry *e, *n;

@ -613,7 +613,7 @@ void hashmap_move(Hashmap * h, Hashmap * other) @@ -613,7 +613,7 @@ void hashmap_move(Hashmap * h, Hashmap * other)
}
}

int hashmap_move_one(Hashmap * h, Hashmap * other, const void *key)
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key)
{
unsigned h_hash, other_hash;
struct hashmap_entry *e;
@ -637,7 +637,7 @@ int hashmap_move_one(Hashmap * h, Hashmap * other, const void *key) @@ -637,7 +637,7 @@ int hashmap_move_one(Hashmap * h, Hashmap * other, const void *key)
return 0;
}

char **hashmap_get_strv(Hashmap * h)
char **hashmap_get_strv(Hashmap *h)
{
char **sv;
Iterator it;

62
install/hashmap.h

@ -44,37 +44,37 @@ unsigned trivial_hash_func(const void *p); @@ -44,37 +44,37 @@ unsigned trivial_hash_func(const void *p);
int trivial_compare_func(const void *a, const void *b);

Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func);
void hashmap_free(Hashmap * h);
void hashmap_free_free(Hashmap * h);
int hashmap_ensure_allocated(Hashmap ** h, hash_func_t hash_func, compare_func_t compare_func);

int hashmap_put(Hashmap * h, const void *key, void *value);
int hashmap_replace(Hashmap * h, const void *key, void *value);
void *hashmap_get(Hashmap * h, const void *key);
void *hashmap_remove(Hashmap * h, const void *key);
void *hashmap_remove_value(Hashmap * h, const void *key, void *value);
int hashmap_remove_and_put(Hashmap * h, const void *old_key, const void *new_key, void *value);
int hashmap_remove_and_replace(Hashmap * h, const void *old_key, const void *new_key, void *value);

int hashmap_merge(Hashmap * h, Hashmap * other);
void hashmap_move(Hashmap * h, Hashmap * other);
int hashmap_move_one(Hashmap * h, Hashmap * other, const void *key);

unsigned hashmap_size(Hashmap * h);
bool hashmap_isempty(Hashmap * h);

void *hashmap_iterate(Hashmap * h, Iterator * i, const void **key);
void *hashmap_iterate_backwards(Hashmap * h, Iterator * i, const void **key);
void *hashmap_iterate_skip(Hashmap * h, const void *key, Iterator * i);

void hashmap_clear(Hashmap * h);
void *hashmap_steal_first(Hashmap * h);
void *hashmap_steal_first_key(Hashmap * h);
void *hashmap_first(Hashmap * h);
void *hashmap_first_key(Hashmap * h);
void *hashmap_last(Hashmap * h);

char **hashmap_get_strv(Hashmap * h);
void hashmap_free(Hashmap *h);
void hashmap_free_free(Hashmap *h);
int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func);

int hashmap_put(Hashmap *h, const void *key, void *value);
int hashmap_replace(Hashmap *h, const void *key, void *value);
void *hashmap_get(Hashmap *h, const void *key);
void *hashmap_remove(Hashmap *h, const void *key);
void *hashmap_remove_value(Hashmap *h, const void *key, void *value);
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value);
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value);

int hashmap_merge(Hashmap *h, Hashmap *other);
void hashmap_move(Hashmap *h, Hashmap *other);
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key);

unsigned hashmap_size(Hashmap *h);
bool hashmap_isempty(Hashmap *h);

void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key);
void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key);
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i);

void hashmap_clear(Hashmap *h);
void *hashmap_steal_first(Hashmap *h);
void *hashmap_steal_first_key(Hashmap *h);
void *hashmap_first(Hashmap *h);
void *hashmap_first_key(Hashmap *h);
void *hashmap_last(Hashmap *h);

char **hashmap_get_strv(Hashmap *h);

#define HASHMAP_FOREACH(e, h, i) \
for ((i) = ITERATOR_FIRST, (e) = hashmap_iterate((h), &(i), NULL); (e); (e) = hashmap_iterate((h), &(i), NULL))

8
install/macro.h

@ -265,10 +265,10 @@ do { \ @@ -265,10 +265,10 @@ do { \
} \
} while(false)

/* Because statfs.t_type can be int on some architecures, we have to cast
* the const magic to the type, otherwise the compiler warns about
* signed/unsigned comparison, because the magic can be 32 bit unsigned.
*/
/* Because statfs.t_type can be int on some architecures, we have to cast
* the const magic to the type, otherwise the compiler warns about
* signed/unsigned comparison, because the magic can be 32 bit unsigned.
*/
#define F_TYPE_CMP(a, b) (a == (typeof(a)) b)

/* Returns the number of chars needed to format variables of the

8
install/strv.c

@ -156,7 +156,7 @@ char **strv_new_ap(const char *x, va_list ap) @@ -156,7 +156,7 @@ char **strv_new_ap(const char *x, va_list ap)

return a;

fail:
fail:
strv_free(a);
return NULL;
}
@ -202,7 +202,7 @@ char **strv_merge(char **a, char **b) @@ -202,7 +202,7 @@ char **strv_merge(char **a, char **b)
*k = NULL;
return r;

fail:
fail:
strv_free(r);
return NULL;
}
@ -237,7 +237,7 @@ char **strv_merge_concat(char **a, char **b, const char *suffix) @@ -237,7 +237,7 @@ char **strv_merge_concat(char **a, char **b, const char *suffix)
*k = NULL;
return r;

fail:
fail:
strv_free(r);
return NULL;

@ -398,7 +398,7 @@ char **strv_append(char **l, const char *s) @@ -398,7 +398,7 @@ char **strv_append(char **l, const char *s)
k[1] = NULL;
return r;

fail:
fail:
strv_free(r);
return NULL;
}

72
install/util.c

@ -358,25 +358,25 @@ char *cunescape_length_with_prefix(const char *s, size_t length, const char *pre @@ -358,25 +358,25 @@ char *cunescape_length_with_prefix(const char *s, size_t length, const char *pre
*(t++) = ' ';
break;

case 'x':{
/* hexadecimal encoding */
int a, b;

a = unhexchar(f[1]);
b = unhexchar(f[2]);

if (a < 0 || b < 0) {
/* Invalid escape code, let's take it literal then */
*(t++) = '\\';
*(t++) = 'x';
} else {
*(t++) = (char)((a << 4) | b);
f += 2;
}

break;
case 'x': {
/* hexadecimal encoding */
int a, b;

a = unhexchar(f[1]);
b = unhexchar(f[2]);

if (a < 0 || b < 0) {
/* Invalid escape code, let's take it literal then */
*(t++) = '\\';
*(t++) = 'x';
} else {
*(t++) = (char)((a << 4) | b);
f += 2;
}

break;
}

case '0':
case '1':
case '2':
@ -384,26 +384,26 @@ char *cunescape_length_with_prefix(const char *s, size_t length, const char *pre @@ -384,26 +384,26 @@ char *cunescape_length_with_prefix(const char *s, size_t length, const char *pre
case '4':
case '5':
case '6':
case '7':{
/* octal encoding */
int a, b, c;

a = unoctchar(f[0]);
b = unoctchar(f[1]);
c = unoctchar(f[2]);

if (a < 0 || b < 0 || c < 0) {
/* Invalid escape code, let's take it literal then */
*(t++) = '\\';
*(t++) = f[0];
} else {
*(t++) = (char)((a << 6) | (b << 3) | c);
f += 2;
}

break;
case '7': {
/* octal encoding */
int a, b, c;

a = unoctchar(f[0]);
b = unoctchar(f[1]);
c = unoctchar(f[2]);

if (a < 0 || b < 0 || c < 0) {
/* Invalid escape code, let's take it literal then */
*(t++) = '\\';
*(t++) = f[0];
} else {
*(t++) = (char)((a << 6) | (b << 3) | c);
f += 2;
}

break;
}

case 0:
/* premature end of string. */
*(t++) = '\\';
@ -417,7 +417,7 @@ char *cunescape_length_with_prefix(const char *s, size_t length, const char *pre @@ -417,7 +417,7 @@ char *cunescape_length_with_prefix(const char *s, size_t length, const char *pre
}
}

finish:
finish:
*t = 0;
return r;
}

62
install/util.h

@ -86,8 +86,8 @@ typedef struct dual_timestamp { @@ -86,8 +86,8 @@ typedef struct dual_timestamp {

usec_t now(clockid_t clock);

dual_timestamp *dual_timestamp_get(dual_timestamp * ts);
dual_timestamp *dual_timestamp_from_realtime(dual_timestamp * ts, usec_t u);
dual_timestamp *dual_timestamp_get(dual_timestamp *ts);
dual_timestamp *dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u);

#define dual_timestamp_is_set(ts) ((ts)->realtime > 0)

@ -158,11 +158,11 @@ void close_nointr_nofail(int fd); @@ -158,11 +158,11 @@ void close_nointr_nofail(int fd);
void close_many(const int fds[], unsigned n_fd);

int parse_boolean(const char *v);
int parse_usec(const char *t, usec_t * usec);
int parse_nsec(const char *t, nsec_t * nsec);
int parse_bytes(const char *t, off_t * bytes);
int parse_pid(const char *s, pid_t * ret_pid);
int parse_uid(const char *s, uid_t * ret_uid);
int parse_usec(const char *t, usec_t *usec);
int parse_nsec(const char *t, nsec_t *nsec);
int parse_bytes(const char *t, off_t *bytes);
int parse_pid(const char *s, pid_t *ret_pid);
int parse_uid(const char *s, uid_t *ret_uid);
#define parse_gid(s, ret_uid) parse_uid(s, ret_uid)

int safe_atou(const char *s, unsigned *ret_u);
@ -197,25 +197,25 @@ static inline int safe_atoli(const char *s, long int *ret_u) @@ -197,25 +197,25 @@ static inline int safe_atoli(const char *s, long int *ret_u)
}
#endif

static inline int safe_atou32(const char *s, uint32_t * ret_u)
static inline int safe_atou32(const char *s, uint32_t *ret_u)
{
assert_cc(sizeof(uint32_t) == sizeof(unsigned));
return safe_atou(s, (unsigned *)ret_u);
}

static inline int safe_atoi32(const char *s, int32_t * ret_i)
static inline int safe_atoi32(const char *s, int32_t *ret_i)
{
assert_cc(sizeof(int32_t) == sizeof(int));
return safe_atoi(s, (int *)ret_i);
}

static inline int safe_atou64(const char *s, uint64_t * ret_u)
static inline int safe_atou64(const char *s, uint64_t *ret_u)
{
assert_cc(sizeof(uint64_t) == sizeof(unsigned long long));
return safe_atollu(s, (unsigned long long *)ret_u);
}

static inline int safe_atoi64(const char *s, int64_t * ret_i)
static inline int safe_atoi64(const char *s, int64_t *ret_i)
{
assert_cc(sizeof(int64_t) == sizeof(long long int));
return safe_atolli(s, (long long int *)ret_i);
@ -233,7 +233,7 @@ char *split_quoted(const char *c, size_t *l, char **state); @@ -233,7 +233,7 @@ char *split_quoted(const char *c, size_t *l, char **state);
#define FOREACH_WORD_QUOTED(word, length, s, state) \
for ((state) = NULL, (word) = split_quoted((s), &(length), &(state)); (word); (word) = split_quoted((s), &(length), &(state)))

pid_t get_parent_of_pid(pid_t pid, pid_t * ppid);
pid_t get_parent_of_pid(pid_t pid, pid_t *ppid);
int get_starttime_of_pid(pid_t pid, unsigned long long *st);

int write_one_line_file(const char *fn, const char *line);
@ -268,7 +268,7 @@ int rmdir_parents(const char *path, const char *stop); @@ -268,7 +268,7 @@ int rmdir_parents(const char *path, const char *stop);
int get_process_comm(pid_t pid, char **name);
int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);
int get_process_exe(pid_t pid, char **name);
int get_process_uid(pid_t pid, uid_t * uid);
int get_process_uid(pid_t pid, uid_t *uid);

char hexchar(int x);
int unhexchar(char c);
@ -337,7 +337,7 @@ bool fstype_is_network(const char *fstype); @@ -337,7 +337,7 @@ bool fstype_is_network(const char *fstype);

int chvt(int vt);

int read_one_char(FILE * f, char *ret, usec_t timeout, bool *need_nl);
int read_one_char(FILE *f, char *ret, usec_t timeout, bool *need_nl);
int ask(char *ret, const char *replies, const char *text, ...);

int reset_terminal_fd(int fd, bool switch_to_text);
@ -354,7 +354,7 @@ int default_signals(int sig, ...); @@ -354,7 +354,7 @@ int default_signals(int sig, ...);
int sigaction_many(const struct sigaction *sa, ...);

int close_pipe(int p[]);
int fopen_temporary(const char *path, FILE ** _f, char **_temp_path);
int fopen_temporary(const char *path, FILE **_f, char **_temp_path);

ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll);
ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
@ -365,7 +365,7 @@ int dir_is_empty(const char *path); @@ -365,7 +365,7 @@ int dir_is_empty(const char *path);

void rename_process(const char name[8]);

void sigset_add_many(sigset_t * ss, ...);
void sigset_add_many(sigset_t *ss, ...);

char *gethostname_malloc(void);
bool hostname_is_set(void);
@ -374,8 +374,8 @@ char *getlogname_malloc(void); @@ -374,8 +374,8 @@ char *getlogname_malloc(void);
int getttyname_malloc(int fd, char **r);
int getttyname_harder(int fd, char **r);

int get_ctty_devnr(pid_t pid, dev_t * d);
int get_ctty(pid_t, dev_t * _devnr, char **r);
int get_ctty_devnr(pid_t pid, dev_t *d);
int get_ctty(pid_t, dev_t *_devnr, char **r);

int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid);
@ -407,7 +407,7 @@ int touch(const char *path); @@ -407,7 +407,7 @@ int touch(const char *path);
char *unquote(const char *s, const char *quotes);
char *normalize_env_assignment(const char *s);

int wait_for_terminate(pid_t pid, siginfo_t * status);
int wait_for_terminate(pid_t pid, siginfo_t *status);
int wait_for_terminate_and_warn(const char *name, pid_t pid);

_noreturn_ void freeze(void);
@ -417,8 +417,8 @@ int null_or_empty_path(const char *fn); @@ -417,8 +417,8 @@ int null_or_empty_path(const char *fn);

DIR *xopendirat(int dirfd, const char *name, int flags);

void dual_timestamp_serialize(FILE * f, const char *name, dual_timestamp * t);
void dual_timestamp_deserialize(const char *value, dual_timestamp * t);
void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t);
void dual_timestamp_deserialize(const char *value, dual_timestamp *t);

char *fstab_node_to_udev_node(const char *p);

@ -428,7 +428,7 @@ bool tty_is_console(const char *tty); @@ -428,7 +428,7 @@ bool tty_is_console(const char *tty);
int vtnr_from_tty(const char *tty);
const char *default_term_for_tty(const char *tty);

void execute_directory(const char *directory, DIR * _d, char *argv[]);
void execute_directory(const char *directory, DIR *_d, char *argv[]);

int kill_and_sigcont(pid_t pid, int sig);

@ -459,14 +459,14 @@ int fchmod_umask(int fd, mode_t mode); @@ -459,14 +459,14 @@ int fchmod_umask(int fd, mode_t mode);
bool display_is_local(const char *display);
int socket_from_display(const char *display, char **path);

int get_user_creds(const char **username, uid_t * uid, gid_t * gid, const char **home);
int get_group_creds(const char **groupname, gid_t * gid);
int get_user_creds(const char **username, uid_t *uid, gid_t *gid, const char **home);
int get_group_creds(const char **groupname, gid_t *gid);

int in_group(const char *name);

int glob_exists(const char *path);

int dirent_ensure_type(DIR * d, struct dirent *de);
int dirent_ensure_type(DIR *d, struct dirent *de);

int in_search_path(const char *path, char **search);
int get_files_in_directory(const char *path, char ***list);
@ -477,7 +477,7 @@ bool is_main_thread(void); @@ -477,7 +477,7 @@ bool is_main_thread(void);

bool in_charset(const char *s, const char *charset);

int block_get_whole_disk(dev_t d, dev_t * ret);
int block_get_whole_disk(dev_t d, dev_t *ret);

int file_is_priv_sticky(const char *p);

@ -535,13 +535,13 @@ static inline void freep(void *p) @@ -535,13 +535,13 @@ static inline void freep(void *p)
free(*(void **)p);
}

static inline void fclosep(FILE ** f)
static inline void fclosep(FILE **f)
{
if (*f)
fclose(*f);
}

static inline void pclosep(FILE ** f)
static inline void pclosep(FILE **f)
{
if (*f)
pclose(*f);
@ -553,13 +553,13 @@ static inline void closep(int *fd) @@ -553,13 +553,13 @@ static inline void closep(int *fd)
close_nointr_nofail(*fd);
}

static inline void closedirp(DIR ** d)
static inline void closedirp(DIR **d)
{
if (*d)
closedir(*d);
}

static inline void umaskp(mode_t * u)
static inline void umaskp(mode_t *u)
{
umask(*u);
}
@ -575,7 +575,7 @@ static inline void umaskp(mode_t * u) @@ -575,7 +575,7 @@ static inline void umaskp(mode_t * u)
int fd_inc_sndbuf(int fd, size_t n);
int fd_inc_rcvbuf(int fd, size_t n);

int fork_agent(pid_t * pid, const int except[], unsigned n_except, const char *path, ...);
int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...);

int setrlimit_closest(int resource, const struct rlimit *rlim);


6
logtee.c

@ -17,9 +17,9 @@ int main(int argc, char *argv[]) @@ -17,9 +17,9 @@ int main(int argc, char *argv[])
int timeout;
char *timeout_env;
struct pollfd fds[] = { {
.fd = STDIN_FILENO,
.events = POLLIN | POLLERR,
}
.fd = STDIN_FILENO,
.events = POLLIN | POLLERR,
}
};

timeout_env = getenv("LOGTEE_TIMEOUT_MS");

Loading…
Cancel
Save