Bug 66068 - [PATCH] several small fix/polish for dbus-launch
Summary: [PATCH] several small fix/polish for dbus-launch
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: 1.5
Hardware: Other All
: medium normal
Assignee: Havoc Pennington
QA Contact:
URL:
Whiteboard: review?
Keywords: patch
Depends on:
Blocks:
 
Reported: 2013-06-23 06:43 UTC by Chengwei Yang
Modified: 2013-09-05 15:16 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
[PATCH 1/5] dbus-launch: fix coding style (2.08 KB, patch)
2013-06-23 06:44 UTC, Chengwei Yang
Details | Splinter Review
[PATCH 2/5] dbus-launch: align document (2.88 KB, patch)
2013-06-23 06:45 UTC, Chengwei Yang
Details | Splinter Review
[PATCH 3/5] dbus-launch: check SIGHUP definition and free args on failure (1.22 KB, patch)
2013-06-23 06:45 UTC, Chengwei Yang
Details | Splinter Review
[PATCH 4/5] dbus-launch: do not verbose output if build with verbose mode disabled (939 bytes, patch)
2013-06-23 06:46 UTC, Chengwei Yang
Details | Splinter Review
[PATCH 5/5] dbus-launch: fix syntax usage (9.70 KB, patch)
2013-06-23 06:46 UTC, Chengwei Yang
Details | Splinter Review
[PATCH v2 1/4] dbus-launch: fix coding style (2.06 KB, patch)
2013-06-26 12:38 UTC, Chengwei Yang
Details | Splinter Review
[PATCH v2 2/4] dbus-launch: align document (2.88 KB, patch)
2013-06-26 12:39 UTC, Chengwei Yang
Details | Splinter Review
[PATCH v2 3/4] dbus-launch: check SIGHUP definition and free args on failure (1.23 KB, patch)
2013-06-26 12:42 UTC, Chengwei Yang
Details | Splinter Review
[PATCH v2 4/4] dbus-launch: do not verbose output if build with verbose mode disabled (906 bytes, patch)
2013-06-26 12:43 UTC, Chengwei Yang
Details | Splinter Review
[PATCH v3] dbus-launch: unconditionally use SIGHUP and free memory on OOM (1.40 KB, patch)
2013-06-27 01:19 UTC, Chengwei Yang
Details | Splinter Review

Description Chengwei Yang 2013-06-23 06:43:48 UTC

    
Comment 1 Chengwei Yang 2013-06-23 06:44:27 UTC
Created attachment 81246 [details] [review]
[PATCH 1/5] dbus-launch: fix coding style
Comment 2 Chengwei Yang 2013-06-23 06:45:01 UTC
Created attachment 81247 [details] [review]
[PATCH 2/5] dbus-launch: align document
Comment 3 Chengwei Yang 2013-06-23 06:45:32 UTC
Created attachment 81248 [details] [review]
[PATCH 3/5] dbus-launch: check SIGHUP definition and free args on  failure
Comment 4 Chengwei Yang 2013-06-23 06:46:01 UTC
Created attachment 81249 [details] [review]
[PATCH 4/5] dbus-launch: do not verbose output if build with verbose  mode disabled
Comment 5 Chengwei Yang 2013-06-23 06:46:32 UTC
Created attachment 81250 [details] [review]
[PATCH 5/5] dbus-launch: fix syntax usage
Comment 6 Simon McVittie 2013-06-26 12:07:53 UTC
Comment on attachment 81246 [details] [review]
[PATCH 1/5] dbus-launch: fix coding style

Review of attachment 81246 [details] [review]:
-----------------------------------------------------------------

Looks good, apart from:

::: tools/dbus-launch.c
@@ +756,5 @@
>        if (envvar == NULL || args == NULL)
>          goto oom;
>  
> +      args[0] = xstrdup (runprog);
> +        if (!args[0])

This extra indent doesn't make sense?
Comment 7 Simon McVittie 2013-06-26 12:08:53 UTC
Comment on attachment 81247 [details] [review]
[PATCH 2/5] dbus-launch: align document

Review of attachment 81247 [details] [review]:
-----------------------------------------------------------------

Makes sense.
Comment 8 Simon McVittie 2013-06-26 12:10:56 UTC
Comment on attachment 81248 [details] [review]
[PATCH 3/5] dbus-launch: check SIGHUP definition and free args on  failure

Review of attachment 81248 [details] [review]:
-----------------------------------------------------------------

::: tools/dbus-launch.c
@@ +479,2 @@
>    sigaction (SIGHUP,  &act, NULL);
> +#endif

What platform "is Unix" but doesn't have SIGHUP?

(The Windows version of dbus-launch is completely separate.)

@@ +768,4 @@
>          {
>            size_t len = strlen (argv[remaining_args+i-1])+1;
>            args[i] = malloc (len);
> +          if (!args[i]) {

That's not our coding style (I realise dbus-launch is a mess, but we use GNU indentation fairly consistently).

@@ +769,5 @@
>            size_t len = strlen (argv[remaining_args+i-1])+1;
>            args[i] = malloc (len);
> +          if (!args[i]) {
> +            while (i > 1)
> +              free(args[--i]);

Maybe. I'd have to check the logic.

It doesn't really matter, since presumably we're about to exit anyway...
Comment 9 Simon McVittie 2013-06-26 12:13:15 UTC
Comment on attachment 81249 [details] [review]
[PATCH 4/5] dbus-launch: do not verbose output if build with verbose  mode disabled

Review of attachment 81249 [details] [review]:
-----------------------------------------------------------------

::: tools/dbus-launch.c
@@ +183,5 @@
> +void
> +verbose (const char *format,
> +         ...)
> +{
> +  ; /* do nothing */

No empty statements (redundant semicolons) please; they're not valid C, strictly speaking, and some compilers fail to compile them. This

   verbose (const char *format,
            ...
   {
   }

should be sufficient (with or without a comment, as you prefer).

You could move the #ifdef inside verbose() to avoid repeating the signature?
Comment 10 Simon McVittie 2013-06-26 12:16:49 UTC
Comment on attachment 81250 [details] [review]
[PATCH 5/5] dbus-launch: fix syntax usage

Review of attachment 81250 [details] [review]:
-----------------------------------------------------------------

Sorry, this is too much code to be worth it. The `eval dbus-launch` form is basically never the best thing to do, particularly now that we have dbus-run-session; I don't want to add more code to support it.
Comment 11 Chengwei Yang 2013-06-26 12:38:17 UTC
Created attachment 81467 [details] [review]
[PATCH v2 1/4] dbus-launch: fix coding style
Comment 12 Chengwei Yang 2013-06-26 12:39:09 UTC
Created attachment 81468 [details] [review]
[PATCH v2 2/4] dbus-launch: align document
Comment 13 Chengwei Yang 2013-06-26 12:42:54 UTC
Created attachment 81470 [details] [review]
[PATCH v2 3/4] dbus-launch: check SIGHUP definition and free args on  failure

I didn't dig into which unix/linux has no SIGHUP, I just add it because it did that in signal_handler. If you're sure it's unnecessary, I'll drop them in v3.

...
static void
signal_handler (int sig)
{
  switch (sig)
    {
#ifdef SIGHUP
    case SIGHUP:
#endif
...
Comment 14 Chengwei Yang 2013-06-26 12:43:36 UTC
Created attachment 81471 [details] [review]
[PATCH v2 4/4] dbus-launch: do not verbose output if build with  verbose mode disabled
Comment 15 Chengwei Yang 2013-06-26 13:39:29 UTC
(In reply to comment #13)
> Created attachment 81470 [details] [review] [review]
> [PATCH v2 3/4] dbus-launch: check SIGHUP definition and free args on  failure
> 
> I didn't dig into which unix/linux has no SIGHUP, I just add it because it
> did that in signal_handler. If you're sure it's unnecessary, I'll drop them
> in v3.
> 
> ...
> static void
> signal_handler (int sig)
> {
>   switch (sig)
>     {
> #ifdef SIGHUP
>     case SIGHUP:
> #endif
> ...

Seems it's for windows.

commit 100027007254aaec3ba0388bd0f42e29e512a678
Author: Tor Lillqvist <tml@iki.fi>
Date:   Thu Sep 18 19:40:50 2008 -0400

    [win32] Protect usage of SIGHUP with #ifdef
    
    Signed-off-by: Colin Walters <walters@verbum.org>
Comment 16 Simon McVittie 2013-06-26 14:27:52 UTC
(In reply to comment #11)
> [PATCH v2 1/4] dbus-launch: fix coding style

Fixed in git for 1.7.6

(In reply to comment #12)
> [PATCH v2 2/4] dbus-launch: align document

Fixed in git for 1.7.6

(In reply to comment #13)
> free args on  failure

I haven't yet checked the logic for this to make sure it's right. It'd be better as a separate commit, probably.

> I didn't dig into which unix/linux has no SIGHUP, I just add it because it
> did that in signal_handler. If you're sure it's unnecessary, I'll drop them
> in v3.

signal_handler() in dbus-launch.c doesn't need to be portable to Windows: Windows builds use dbus-launch-win.c instead. So, just use SIGHUP unconditionally there.

It looks like unnecessary copy/paste from bus/main.c, which *does* need to be portable to Windows.

(In reply to comment #14)
> [PATCH v2 4/4] dbus-launch: do not verbose output if build with  verbose
> mode disabled

Fixed in git for 1.7.6
Comment 17 Chengwei Yang 2013-06-27 01:19:46 UTC
Created attachment 81519 [details] [review]
[PATCH v3] dbus-launch: unconditionally use SIGHUP and free memory  on OOM
Comment 18 Simon McVittie 2013-09-05 15:16:56 UTC
Fixed in git for 1.7.6, thanks.

Please note in future: our coding style for function calls is "free (x)", not "free(x)".


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.