chiark / gitweb /
don't use 'long long' unless we have a really good reason to
authorLennart Poettering <lennart@poettering.net>
Sat, 19 Jun 2010 02:35:52 +0000 (04:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 19 Jun 2010 02:35:52 +0000 (04:35 +0200)
fixme
src/execute.c
src/initctl.c
src/log.c
src/logger.c
src/main.c
src/manager.c
src/mount.c
src/service.c
src/socket.c
src/util.c

diff --git a/fixme b/fixme
index a366ea83a56bff53df069f1a996da45c8a9be4b2..9152a2521d828d3b698c435c039b0fb0651e7312 100644 (file)
--- a/fixme
+++ b/fixme
@@ -18,8 +18,6 @@
 
 * "disabled" load state?
 
-* uid are 32bit
-
 * %m in printf() instead of strerror();
 
 * gc: don't reap broken services
index 28baeedcfc44c9ca3c359ef28ff26390a57dc198..d5bb8d3602920510e3fdb4e46db6a6d544f9b612 100644 (file)
@@ -1213,7 +1213,7 @@ int exec_spawn(ExecCommand *command,
                 }
 
                 if (n_fds > 0)
-                        if (asprintf(our_env + n_env++, "LISTEN_PID=%llu", (unsigned long long) getpid()) < 0 ||
+                        if (asprintf(our_env + n_env++, "LISTEN_PID=%lu", (unsigned long) getpid()) < 0 ||
                             asprintf(our_env + n_env++, "LISTEN_FDS=%u", n_fds) < 0) {
                                 r = EXIT_MEMORY;
                                 goto fail;
@@ -1270,7 +1270,7 @@ int exec_spawn(ExecCommand *command,
         if (cgroup_bondings)
                 cgroup_bonding_install_list(cgroup_bondings, pid);
 
-        log_debug("Forked %s as %llu", command->path, (unsigned long long) pid);
+        log_debug("Forked %s as %lu", command->path, (unsigned long) pid);
 
         command->exec_status.pid = pid;
         command->exec_status.start_timestamp = now(CLOCK_REALTIME);
@@ -1572,8 +1572,8 @@ void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix) {
                 return;
 
         fprintf(f,
-                "%sPID: %llu\n",
-                prefix, (unsigned long long) s->pid);
+                "%sPID: %lu\n",
+                prefix, (unsigned long) s->pid);
 
         if (s->start_timestamp > 0)
                 fprintf(f,
index fef45007ba8c49a3641648f244368bbe8b4c655d..def621d220298568fc1782fcca8b55b16e3f4e1f 100644 (file)
@@ -339,7 +339,7 @@ int main(int argc, char *argv[]) {
         log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
         log_parse_environment();
 
-        log_info("systemd-initctl running as pid %llu", (unsigned long long) getpid());
+        log_info("systemd-initctl running as pid %lu", (unsigned long) getpid());
 
         if ((n = sd_listen_fds(true)) < 0) {
                 log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
@@ -387,7 +387,7 @@ fail:
 
         server_done(&server);
 
-        log_info("systemd-initctl stopped as pid %llu", (unsigned long long) getpid());
+        log_info("systemd-initctl stopped as pid %lu", (unsigned long) getpid());
 
         dbus_shutdown();
 
index 4f9f2da2592c5a99ad96eec34ba5d7b927afbbcb..4840185bc1cabb7896b163494c90211cd03e4649 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -265,7 +265,7 @@ static int write_to_syslog(
         if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)
                 return -EINVAL;
 
-        snprintf(header_pid, sizeof(header_pid), "[%llu]: ", (unsigned long long) getpid());
+        snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
         char_array_0(header_pid);
 
         zero(iovec);
@@ -301,7 +301,7 @@ static int write_to_kmsg(
         snprintf(header_priority, sizeof(header_priority), "<%i>", LOG_PRI(level));
         char_array_0(header_priority);
 
-        snprintf(header_pid, sizeof(header_pid), "[%llu]: ", (unsigned long long) getpid());
+        snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
         char_array_0(header_pid);
 
         zero(iovec);
index de4dfad38603c680f02f4d62ef14e94de49aec80..66f6f8c2e5b3f71da5be1328abd91775d2ce841b 100644 (file)
@@ -143,7 +143,7 @@ static int stream_log(Stream *s, char *p, usec_t ts) {
                         return -EINVAL;
         }
 
-        snprintf(header_pid, sizeof(header_pid), "[%llu]: ", (unsigned long long) s->pid);
+        snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) s->pid);
         char_array_0(header_pid);
 
         zero(iovec);
@@ -538,7 +538,7 @@ int main(int argc, char *argv[]) {
         log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
         log_parse_environment();
 
-        log_info("systemd-logger running as pid %llu", (unsigned long long) getpid());
+        log_info("systemd-logger running as pid %lu", (unsigned long) getpid());
 
         if ((n = sd_listen_fds(true)) < 0) {
                 log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
@@ -586,7 +586,7 @@ fail:
 
         server_done(&server);
 
-        log_info("systemd-logger stopped as pid %llu", (unsigned long long) getpid());
+        log_info("systemd-logger stopped as pid %lu", (unsigned long) getpid());
 
         return r;
 }
index f00d43a7c5bf16daf197bbad03f07bf12f8fa4c4..db2a767818364458c3268739ac7493b3f85e859b 100644 (file)
@@ -116,7 +116,7 @@ _noreturn_ static void crash(int sig) {
                         else if (!WCOREDUMP(status))
                                 log_error("Caught <%s>, core dump failed.", strsignal(sig));
                         else
-                                log_error("Caught <%s>, dumped core as pid %llu.", strsignal(sig), (unsigned long long) pid);
+                                log_error("Caught <%s>, dumped core as pid %lu.", strsignal(sig), (unsigned long) pid);
                 }
         }
 
@@ -152,7 +152,7 @@ _noreturn_ static void crash(int sig) {
                         _exit(1);
                 }
 
-                log_info("Successfully spawned crash shall as pid %llu.", (unsigned long long) pid);
+                log_info("Successfully spawned crash shall as pid %lu.", (unsigned long) pid);
         }
 
         log_info("Freezing execution.");
index e211ecaf56c3851fb63268e3c8c4e4a2e7c125ab..da42d7d78b573e5a366a04861a442416a51b43b1 100644 (file)
@@ -1701,7 +1701,7 @@ static int manager_dispatch_sigchld(Manager *m) {
                         char *name = NULL;
 
                         get_process_name(si.si_pid, &name);
-                        log_debug("Got SIGCHLD for process %llu (%s)", (unsigned long long) si.si_pid, strna(name));
+                        log_debug("Got SIGCHLD for process %lu (%s)", (unsigned long) si.si_pid, strna(name));
                         free(name);
                 }
 
@@ -1727,8 +1727,8 @@ static int manager_dispatch_sigchld(Manager *m) {
                 if (si.si_code != CLD_EXITED && si.si_code != CLD_KILLED && si.si_code != CLD_DUMPED)
                         continue;
 
-                log_debug("Child %llu died (code=%s, status=%i/%s)",
-                          (long long unsigned) si.si_pid,
+                log_debug("Child %lu died (code=%s, status=%i/%s)",
+                          (long unsigned) si.si_pid,
                           sigchld_code_to_string(si.si_code),
                           si.si_status,
                           strna(si.si_code == CLD_EXITED ? exit_status_to_string(si.si_status) : strsignal(si.si_status)));
index 5c16f86d539213e46270e9b87c4c6beab21527d1..b49c64aeabc7b287c171cc8bf45fcc7b4d7f36fa 100644 (file)
@@ -505,8 +505,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (m->control_pid > 0)
                 fprintf(f,
-                        "%sControl PID: %llu\n",
-                        prefix, (unsigned long long) m->control_pid);
+                        "%sControl PID: %lu\n",
+                        prefix, (unsigned long) m->control_pid);
 
         exec_context_dump(&m->exec_context, f, prefix);
 }
index 4375cb5cb1b9cbf70633bf631bced49869ca3521..987320178a785afcb20b5179e18e93d5dc7944fe 100644 (file)
@@ -904,13 +904,13 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (s->control_pid > 0)
                 fprintf(f,
-                        "%sControl PID: %llu\n",
-                        prefix, (unsigned long long) s->control_pid);
+                        "%sControl PID: %lu\n",
+                        prefix, (unsigned long) s->control_pid);
 
         if (s->main_pid > 0)
                 fprintf(f,
-                        "%sMain PID: %llu\n",
-                        prefix, (unsigned long long) s->main_pid);
+                        "%sMain PID: %lu\n",
+                        prefix, (unsigned long) s->main_pid);
 
         if (s->pid_file)
                 fprintf(f,
index fdb6f66b6fd79c16470a7976875367ca644ec339..751d8aa8fa5bf4479176d19fcf83c698a1026353 100644 (file)
@@ -313,8 +313,8 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (s->control_pid > 0)
                 fprintf(f,
-                        "%sControl PID: %llu\n",
-                        prefix, (unsigned long long) s->control_pid);
+                        "%sControl PID: %lu\n",
+                        prefix, (unsigned long) s->control_pid);
 
         if (s->bind_to_device)
                 fprintf(f,
@@ -447,10 +447,10 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) {
                         return -errno;
 
                 if (asprintf(&r,
-                             "%u-%llu-%llu",
+                             "%u-%lu-%lu",
                              nr,
-                             (unsigned long long) ucred.pid,
-                             (unsigned long long) ucred.uid) < 0)
+                             (unsigned long) ucred.pid,
+                             (unsigned long) ucred.uid) < 0)
                         return -ENOMEM;
 
                 break;
index 766aa02965825651481d6bdf4146372a72f50def..6fa9dec3a6532cf4de57ba8b554c1bda1de3680a 100644 (file)
@@ -446,12 +446,12 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
         int r;
         FILE *f;
         char fn[132], line[256], *p;
-        long long unsigned ppid;
+        long unsigned ppid;
 
         assert(pid >= 0);
         assert(_ppid);
 
-        assert_se(snprintf(fn, sizeof(fn)-1, "/proc/%llu/stat", (unsigned long long) pid) < (int) (sizeof(fn)-1));
+        assert_se(snprintf(fn, sizeof(fn)-1, "/proc/%lu/stat", (unsigned long) pid) < (int) (sizeof(fn)-1));
         fn[sizeof(fn)-1] = 0;
 
         if (!(f = fopen(fn, "r")))
@@ -476,11 +476,11 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
 
         if (sscanf(p, " "
                    "%*c "  /* state */
-                   "%llu ", /* ppid */
+                   "%lu ", /* ppid */
                    &ppid) != 1)
                 return -EIO;
 
-        if ((long long unsigned) (pid_t) ppid != ppid)
+        if ((long unsigned) (pid_t) ppid != ppid)
                 return -ERANGE;
 
         *_ppid = (pid_t) ppid;
@@ -552,7 +552,7 @@ int get_process_name(pid_t pid, char **name) {
         assert(pid >= 1);
         assert(name);
 
-        if (asprintf(&p, "/proc/%llu/comm", (unsigned long long) pid) < 0)
+        if (asprintf(&p, "/proc/%lu/comm", (unsigned long) pid) < 0)
                 return -ENOMEM;
 
         r = read_one_line_file(p, name);