From: Lennart Poettering Date: Thu, 7 Apr 2011 16:48:50 +0000 (+0200) Subject: don't make up buffer sizes, use standard LINE_MAX instead X-Git-Tag: v25~79 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20c03b7be2c87ef54533db849fd046d7014c36b4;p=systemd don't make up buffer sizes, use standard LINE_MAX instead --- diff --git a/src/dbus-manager.c b/src/dbus-manager.c index 2f755bcc..5b5bda21 100644 --- a/src/dbus-manager.c +++ b/src/dbus-manager.c @@ -218,7 +218,7 @@ static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_exec_output, exec_outp static int bus_manager_append_tainted(Manager *m, DBusMessageIter *i, const char *property, void *data) { const char *t; - char buf[64] = "", *e = buf, *p = NULL; + char buf[LINE_MAX] = "", *e = buf, *p = NULL; assert(m); assert(i); diff --git a/src/log.c b/src/log.c index 95c27656..3776f0d9 100644 --- a/src/log.c +++ b/src/log.c @@ -238,11 +238,11 @@ void log_set_max_level(int level) { } static int write_to_console( - int level, - const char*file, - int line, - const char *func, - const char *buffer) { + int level, + const char*file, + int line, + const char *func, + const char *buffer) { char location[64]; struct iovec iovec[5]; diff --git a/src/manager.c b/src/manager.c index f9b3b595..5cb3588c 100644 --- a/src/manager.c +++ b/src/manager.c @@ -2681,7 +2681,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { m->n_deserializing ++; for (;;) { - char line[1024], *l; + char line[LINE_MAX], *l; if (!fgets(line, sizeof(line), f)) { if (feof(f)) diff --git a/src/mount-setup.c b/src/mount-setup.c index 9bc8946d..4fa8ae5f 100644 --- a/src/mount-setup.c +++ b/src/mount-setup.c @@ -134,7 +134,7 @@ static int mount_one(const MountPoint *p) { static int mount_cgroup_controllers(void) { int r; FILE *f; - char buf [256]; + char buf[LINE_MAX]; /* Mount all available cgroup controllers that are built into the kernel. */ diff --git a/src/readahead-common.c b/src/readahead-common.c index fc49a331..8a75b2e1 100644 --- a/src/readahead-common.c +++ b/src/readahead-common.c @@ -209,7 +209,6 @@ finish: return m; } - #define BUMP_REQUEST_NR (16*1024) int bump_request_nr(const char *p) { diff --git a/src/unit.c b/src/unit.c index 32071f21..37a7c07a 100644 --- a/src/unit.c +++ b/src/unit.c @@ -2152,7 +2152,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) { return 0; for (;;) { - char line[1024], *l, *v; + char line[LINE_MAX], *l, *v; size_t k; if (!fgets(line, sizeof(line), f)) { diff --git a/src/util.c b/src/util.c index 5daafdf7..d39cb483 100644 --- a/src/util.c +++ b/src/util.c @@ -452,7 +452,7 @@ char **split_path_and_make_absolute(const char *p) { int get_parent_of_pid(pid_t pid, pid_t *_ppid) { int r; FILE *f; - char fn[132], line[256], *p; + char fn[PATH_MAX], line[LINE_MAX], *p; long unsigned ppid; assert(pid >= 0); @@ -2063,7 +2063,7 @@ int chvt(int vt) { int read_one_char(FILE *f, char *ret, bool *need_nl) { struct termios old_termios, new_termios; char c; - char line[1024]; + char line[LINE_MAX]; assert(f); assert(ret); @@ -2271,7 +2271,7 @@ int flush_fd(int fd) { pollfd.events = POLLIN; for (;;) { - char buf[1024]; + char buf[LINE_MAX]; ssize_t l; int r; @@ -2897,7 +2897,7 @@ int getttyname_harder(int fd, char **r) { int get_ctty_devnr(dev_t *d) { int k; - char line[256], *p; + char line[LINE_MAX], *p; unsigned long ttynr; FILE *f; @@ -2932,7 +2932,7 @@ int get_ctty_devnr(dev_t *d) { int get_ctty(char **r, dev_t *_devnr) { int k; - char fn[128], *s, *b, *p; + char fn[PATH_MAX], *s, *b, *p; dev_t devnr; assert(r);