After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 315278 - Possible cleanup in gmain.c
Possible cleanup in gmain.c
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2005-09-05 09:35 UTC by Kjartan Maraas
Modified: 2005-09-11 15:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
possbile cleanups (2.20 KB, patch)
2005-09-05 09:36 UTC, Kjartan Maraas
none Details | Review
updated patch (1.30 KB, patch)
2005-09-06 11:30 UTC, Kjartan Maraas
none Details | Review
updated patch (1.30 KB, patch)
2005-09-06 12:52 UTC, Kjartan Maraas
accepted-commit_now Details | Review

Description Kjartan Maraas 2005-09-05 09:35:49 UTC
The Intel compiler complains about some cases of dead code in here and when I
started poking at it there was a bit of the old snowball effect :-)
Comment 1 Kjartan Maraas 2005-09-05 09:36:13 UTC
Sorry, wrong version.
Comment 2 Kjartan Maraas 2005-09-05 09:36:49 UTC
Created attachment 51819 [details] [review]
possbile cleanups
Comment 3 Owen Taylor 2005-09-05 12:42:30 UTC
The child_watch_helper_thread thread change looks fine (check to make sure
that GCC doesn't warn about the removal of the trailing return NULL.)

Maybe you can explain the rest of the patch? It doesn't make immediate sense
to me. (Or look like it would even compile.)
Comment 4 Kjartan Maraas 2005-09-05 13:41:30 UTC
icc complained that child_watch_source was set but never used in
g_child_watch_check() so I removed those two lines. While there I noticed that
g_child_watch_prepare() had the same issue and after removing those lines from
there it ended up just setting timeout = -1 and returning. So I looked for uses
of that function in that file since it was static and there were none. So if the
function was unused and static I figured it also didn't need to be ported to
Win32. It does compile here with icc, trying gcc now...it compiles but with the
following warning:

gmain.c:286: warning: initialization from incompatible pointer type
gmain.c:287: warning: initialization from incompatible pointer type

Looking at the code it's clear that removing it is probably the wrong thing to
do, but is icc right in complaining about the variables being set and never used?
Comment 5 Owen Taylor 2005-09-05 14:36:06 UTC
You are right that the variables can be removed, but I think you missed
the fact the the return statement does the actual work:

  return check_for_child_exited (source);

The function is used as a function pointer:

GSourceFuncs g_child_watch_funcs =
{
  g_child_watch_prepare,
  g_child_watch_check,
  g_child_watch_dispatch,
  NULL
};

This gives a list of functions for the main looop to use at various
stages. If you remove the first line, then you have check in the prepare
slot and dispatch in the check slot, and NULL in the dispatch slot,
and things wont' work at all well :-)
Comment 6 Kjartan Maraas 2005-09-06 11:27:44 UTC
Indeed I did ;-)

So, after removing the fluff we have two matching functions with different names
only one of them takes a gint parameter that it never uses for anything...
Comment 7 Kjartan Maraas 2005-09-06 11:30:43 UTC
Created attachment 51863 [details] [review]
updated patch
Comment 8 Owen Taylor 2005-09-06 12:42:16 UTC
The *timeout = -1 (note the '*') is not extraneous and cannot be removed.
Comment 9 Kjartan Maraas 2005-09-06 12:52:15 UTC
Created attachment 51864 [details] [review]
updated patch

Hopefully this time it's correct then :-)
Comment 10 Matthias Clasen 2005-09-07 03:12:29 UTC
Yes, looks correct now. Please commit to head only.
Comment 11 Kjartan Maraas 2005-09-11 15:20:29 UTC
Commited.