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
=== modified file 'init/job_process.c'
--- init/job_process.c 2012-08-02 08:57:20 +0000
+++ init/job_process.c 2012-08-09 07:49:18 +0000
@@ -405,7 +405,6 @@
405 int pty_master = -1;405 int pty_master = -1;
406 int pty_slave = -1;406 int pty_slave = -1;
407 char pts_name[PATH_MAX];407 char pts_name[PATH_MAX];
408 char filename[PATH_MAX];
409 FILE *fd;408 FILE *fd;
410 int user_job = FALSE;409 int user_job = FALSE;
411 nih_local char *user_dir = NULL;410 nih_local char *user_dir = NULL;
@@ -783,6 +782,7 @@
783 */782 */
784 if (class->oom_score_adj != JOB_DEFAULT_OOM_SCORE_ADJ) {783 if (class->oom_score_adj != JOB_DEFAULT_OOM_SCORE_ADJ) {
785 int oom_value;784 int oom_value;
785 char filename[PATH_MAX];
786 snprintf (filename, sizeof (filename),786 snprintf (filename, sizeof (filename),
787 "/proc/%d/oom_score_adj", getpid ());787 "/proc/%d/oom_score_adj", getpid ());
788 oom_value = class->oom_score_adj;788 oom_value = class->oom_score_adj;
789789
=== modified file 'init/log.c'
--- init/log.c 2012-03-16 21:06:11 +0000
+++ init/log.c 2012-08-09 07:49:18 +0000
@@ -208,9 +208,6 @@
208static void208static void
209log_flush (Log *log)209log_flush (Log *log)
210{210{
211 int ret;
212 int flags;
213
214 nih_assert (log);211 nih_assert (log);
215212
216 /* User job logging not currently available */213 /* User job logging not currently available */
@@ -223,6 +220,7 @@
223 * If any failures occur at this stage, we are powerless.220 * If any failures occur at this stage, we are powerless.
224 */221 */
225 if (log->unflushed->len) {222 if (log->unflushed->len) {
223 int ret;
226 if (log_file_open (log) < 0)224 if (log_file_open (log) < 0)
227 goto out;225 goto out;
228226
@@ -246,7 +244,7 @@
246 if (! log->remote_closed)244 if (! log->remote_closed)
247 log_read_watch (log);245 log_read_watch (log);
248246
249 flags = fcntl (log->io->watch->fd, F_GETFL);247 int flags = fcntl (log->io->watch->fd, F_GETFL);
250248
251 if (flags < 0 && errno == EBADF) {249 if (flags < 0 && errno == EBADF) {
252 /* The watch fd is now known to be invalid, so disable250 /* The watch fd is now known to be invalid, so disable
253251
=== modified file 'init/parse_job.c'
--- init/parse_job.c 2012-02-16 15:45:41 +0000
+++ init/parse_job.c 2012-08-09 07:49:18 +0000
@@ -1847,7 +1847,6 @@
1847 nih_return_error (-1, PARSE_ILLEGAL_INTERVAL,1847 nih_return_error (-1, PARSE_ILLEGAL_INTERVAL,
1848 _(PARSE_ILLEGAL_INTERVAL_STR));1848 _(PARSE_ILLEGAL_INTERVAL_STR));
1849 } else if (! strcmp (arg, "signal")) {1849 } else if (! strcmp (arg, "signal")) {
1850 unsigned long status;
1851 nih_local char *sigarg = NULL;1850 nih_local char *sigarg = NULL;
1852 int signal;1851 int signal;
18531852
@@ -1865,7 +1864,7 @@
1865 signal = nih_signal_from_name (sigarg);1864 signal = nih_signal_from_name (sigarg);
1866 if (signal < 0) {1865 if (signal < 0) {
1867 errno = 0;1866 errno = 0;
1868 status = strtoul (sigarg, &endptr, 10);1867 unsigned long status = strtoul (sigarg, &endptr, 10);
1869 if (errno || *endptr || (status > INT_MAX))1868 if (errno || *endptr || (status > INT_MAX))
1870 nih_return_error (-1, PARSE_ILLEGAL_SIGNAL,1869 nih_return_error (-1, PARSE_ILLEGAL_SIGNAL,
1871 _(PARSE_ILLEGAL_SIGNAL_STR));1870 _(PARSE_ILLEGAL_SIGNAL_STR));
@@ -2285,7 +2284,6 @@
2285 nih_local char *arg = NULL;2284 nih_local char *arg = NULL;
2286 char *endptr;2285 char *endptr;
2287 size_t a_pos, a_lineno;2286 size_t a_pos, a_lineno;
2288 int oom_adj;
2289 int ret = -1;2287 int ret = -1;
22902288
2291 nih_assert (class != NULL);2289 nih_assert (class != NULL);
@@ -2328,7 +2326,7 @@
2328 class->oom_score_adj = -1000;2326 class->oom_score_adj = -1000;
2329 } else {2327 } else {
2330 errno = 0;2328 errno = 0;
2331 oom_adj = (int)strtol (arg, &endptr, 10);2329 int oom_adj = (int)strtol (arg, &endptr, 10);
2332 class->oom_score_adj = (oom_adj * 1000) / ((oom_adj < 0) ? 17 : 15);2330 class->oom_score_adj = (oom_adj * 1000) / ((oom_adj < 0) ? 17 : 15);
2333 if (errno || *endptr || (oom_adj < -17) || (oom_adj > 15))2331 if (errno || *endptr || (oom_adj < -17) || (oom_adj > 15))
2334 nih_return_error (-1, PARSE_ILLEGAL_OOM,2332 nih_return_error (-1, PARSE_ILLEGAL_OOM,
23352333
=== modified file 'util/initctl.c'
--- util/initctl.c 2012-03-16 21:02:13 +0000
+++ util/initctl.c 2012-08-09 07:49:18 +0000
@@ -1331,7 +1331,6 @@
1331{1331{
1332 nih_local NihDBusProxy *upstart = NULL;1332 nih_local NihDBusProxy *upstart = NULL;
1333 const char * upstart_job = NULL;1333 const char * upstart_job = NULL;
1334 const char * upstart_instance = NULL;
1335 nih_local char * job_class_name = NULL;1334 nih_local char * job_class_name = NULL;
1336 nih_local char * job_class_path = NULL;1335 nih_local char * job_class_path = NULL;
1337 nih_local NihDBusProxy *job_class = NULL;1336 nih_local NihDBusProxy *job_class = NULL;
@@ -1346,6 +1345,7 @@
1346 if (args[0]) {1345 if (args[0]) {
1347 upstart_job = args[0];1346 upstart_job = args[0];
1348 } else {1347 } else {
1348 const char * upstart_instance = NULL;
1349 upstart_job = getenv ("UPSTART_JOB");1349 upstart_job = getenv ("UPSTART_JOB");
1350 upstart_instance = getenv ("UPSTART_INSTANCE");1350 upstart_instance = getenv ("UPSTART_INSTANCE");
13511351

Subscribers

People subscribed via source and target branches