Merge lp:~mc-return/upstart/upstart.merge-reduce-scopes-of-various-variables into lp:upstart

Proposed by MC Return
Status: Rejected
Rejected by: James Hunt
Proposed branch: lp:~mc-return/upstart/upstart.merge-reduce-scopes-of-various-variables
Merge into: lp:upstart
Diff against target: 107 lines (+6/-10)
4 files modified
init/job_process.c (+1/-1)
init/log.c (+2/-4)
init/parse_job.c (+2/-4)
util/initctl.c (+1/-1)
To merge this branch: bzr merge lp:~mc-return/upstart/upstart.merge-reduce-scopes-of-various-variables
Reviewer Review Type Date Requested Status
James Hunt Pending
Review via email: mp+118890@code.launchpad.net

Commit message

Reduced the scope of various variables.

Description of the change

Reduces the scope of various variables.

To post a comment you must log in.
1384. By MC Return

Fixed wrong variable type (it was unsigned long, not unsigned int)

Revision history for this message
James Hunt (jamesodhunt) wrote :

Thank you for the contribution, however I'm not entirely convinced of the need to make these changes.

If you'd like to help out in other ways, I'd encourage you to take a look at the bug list:

    https://bugs.launchpad.net/upstart

Thanks for taking an interest!

Unmerged revisions

1384. By MC Return

Fixed wrong variable type (it was unsigned long, not unsigned int)

1383. By MC Return

Reduced the scope of the variable upstart_instance

1382. By MC Return

Reduced the scope of the variable 'oom_adj'

1381. By MC Return

Reduced the scope of the variable 'status'

1380. By MC Return

Reduced the scope of the variable 'flags'

1379. By MC Return

Reduced the scope of the variable 'ret'

1378. By MC Return

Reduced the scope of the variable 'filename'

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'init/job_process.c'
2--- init/job_process.c 2012-08-02 08:57:20 +0000
3+++ init/job_process.c 2012-08-09 07:49:18 +0000
4@@ -405,7 +405,6 @@
5 int pty_master = -1;
6 int pty_slave = -1;
7 char pts_name[PATH_MAX];
8- char filename[PATH_MAX];
9 FILE *fd;
10 int user_job = FALSE;
11 nih_local char *user_dir = NULL;
12@@ -783,6 +782,7 @@
13 */
14 if (class->oom_score_adj != JOB_DEFAULT_OOM_SCORE_ADJ) {
15 int oom_value;
16+ char filename[PATH_MAX];
17 snprintf (filename, sizeof (filename),
18 "/proc/%d/oom_score_adj", getpid ());
19 oom_value = class->oom_score_adj;
20
21=== modified file 'init/log.c'
22--- init/log.c 2012-03-16 21:06:11 +0000
23+++ init/log.c 2012-08-09 07:49:18 +0000
24@@ -208,9 +208,6 @@
25 static void
26 log_flush (Log *log)
27 {
28- int ret;
29- int flags;
30-
31 nih_assert (log);
32
33 /* User job logging not currently available */
34@@ -223,6 +220,7 @@
35 * If any failures occur at this stage, we are powerless.
36 */
37 if (log->unflushed->len) {
38+ int ret;
39 if (log_file_open (log) < 0)
40 goto out;
41
42@@ -246,7 +244,7 @@
43 if (! log->remote_closed)
44 log_read_watch (log);
45
46- flags = fcntl (log->io->watch->fd, F_GETFL);
47+ int flags = fcntl (log->io->watch->fd, F_GETFL);
48
49 if (flags < 0 && errno == EBADF) {
50 /* The watch fd is now known to be invalid, so disable
51
52=== modified file 'init/parse_job.c'
53--- init/parse_job.c 2012-02-16 15:45:41 +0000
54+++ init/parse_job.c 2012-08-09 07:49:18 +0000
55@@ -1847,7 +1847,6 @@
56 nih_return_error (-1, PARSE_ILLEGAL_INTERVAL,
57 _(PARSE_ILLEGAL_INTERVAL_STR));
58 } else if (! strcmp (arg, "signal")) {
59- unsigned long status;
60 nih_local char *sigarg = NULL;
61 int signal;
62
63@@ -1865,7 +1864,7 @@
64 signal = nih_signal_from_name (sigarg);
65 if (signal < 0) {
66 errno = 0;
67- status = strtoul (sigarg, &endptr, 10);
68+ unsigned long status = strtoul (sigarg, &endptr, 10);
69 if (errno || *endptr || (status > INT_MAX))
70 nih_return_error (-1, PARSE_ILLEGAL_SIGNAL,
71 _(PARSE_ILLEGAL_SIGNAL_STR));
72@@ -2285,7 +2284,6 @@
73 nih_local char *arg = NULL;
74 char *endptr;
75 size_t a_pos, a_lineno;
76- int oom_adj;
77 int ret = -1;
78
79 nih_assert (class != NULL);
80@@ -2328,7 +2326,7 @@
81 class->oom_score_adj = -1000;
82 } else {
83 errno = 0;
84- oom_adj = (int)strtol (arg, &endptr, 10);
85+ int oom_adj = (int)strtol (arg, &endptr, 10);
86 class->oom_score_adj = (oom_adj * 1000) / ((oom_adj < 0) ? 17 : 15);
87 if (errno || *endptr || (oom_adj < -17) || (oom_adj > 15))
88 nih_return_error (-1, PARSE_ILLEGAL_OOM,
89
90=== modified file 'util/initctl.c'
91--- util/initctl.c 2012-03-16 21:02:13 +0000
92+++ util/initctl.c 2012-08-09 07:49:18 +0000
93@@ -1331,7 +1331,6 @@
94 {
95 nih_local NihDBusProxy *upstart = NULL;
96 const char * upstart_job = NULL;
97- const char * upstart_instance = NULL;
98 nih_local char * job_class_name = NULL;
99 nih_local char * job_class_path = NULL;
100 nih_local NihDBusProxy *job_class = NULL;
101@@ -1346,6 +1345,7 @@
102 if (args[0]) {
103 upstart_job = args[0];
104 } else {
105+ const char * upstart_instance = NULL;
106 upstart_job = getenv ("UPSTART_JOB");
107 upstart_instance = getenv ("UPSTART_INSTANCE");
108

Subscribers

People subscribed via source and target branches