hal: Branch 'master' - 5 commits
Sjoerd Simons
sjoerd at kemper.freedesktop.org
Wed Dec 5 13:37:12 PST 2007
hald-runner/main.c | 5 +++--
hald-runner/runner.c | 3 ++-
hald/device.c | 25 ++++++++-----------------
3 files changed, 13 insertions(+), 20 deletions(-)
New commits:
commit fc5303b493f96c6958308a3072d6bb99a3409f9b
Merge: 533e321... df92c43...
Author: Sjoerd Simons <sjoerd at luon.net>
Date: Wed Dec 5 22:03:09 2007 +0100
Merge branch 'master' of ssh://git.freedesktop.org/git/hal
commit 533e321c80db8a29fa562c498c8c0199d61cf039
Author: Sjoerd Simons <sjoerd at luon.net>
Date: Sun Dec 2 22:17:27 2007 +0100
use GString to convert a strlist propery to string instead of a static buffer
Instead of a static 256 chars buffer use a GString when converting strlist
properties to string. This prevents clipping the list.
Also fixes a hal crash because the old code didn't do a proper \0 terminate
when the string overflowed (strncpy is a very nice function *cough*).
Eventually the string containing garbage would be passed over dbus to the
runner which would disconnect from the private bus.
diff --git a/hald/device.c b/hald/device.c
index 9514c9d..a3b84f4 100644
--- a/hald/device.c
+++ b/hald/device.c
@@ -160,28 +160,19 @@ hal_property_to_string (HalProperty *prop)
case HAL_PROPERTY_TYPE_STRLIST:
{
GSList *iter;
- guint i;
- char buf[256];
+ GString *buf;
+
+ buf = g_string_new ("");
- i = 0;
- buf[0] = '\0';
- for (iter = hal_property_get_strlist (prop);
- iter != NULL && i < sizeof(buf);
+ for (iter = hal_property_get_strlist (prop); iter != NULL;
iter = g_slist_next (iter)) {
- guint len;
- const char *str;
-
- str = (const char *) iter->data;
- len = strlen (str);
- strncpy (buf + i, str, sizeof(buf) - i);
- i += len;
+ g_string_append (buf, (const char *) iter->data);
- if (g_slist_next (iter) != NULL && i < sizeof(buf)) {
- buf[i] = '\t';
- i++;
+ if (g_slist_next (iter) != NULL) {
+ g_string_append_c(buf, '\t');
}
}
- return g_strdup (buf);
+ return g_string_free (buf, FALSE);
}
default:
commit 235b1af8625e3c4ce9d1e4d7557a0ff8eb90b232
Merge: 13e70a9... 45edb37...
Author: Sjoerd Simons <sjoerd at luon.net>
Date: Sun Dec 2 20:40:55 2007 +0100
Merge branch 'master' of ssh://git.freedesktop.org/git/hal
commit 13e70a9cdf368dcb63541ec53b2e52cab0a72e89
Merge: d314cab... 6aa022d...
Author: Sjoerd Simons <sjoerd at luon.net>
Date: Sun Nov 25 12:55:35 2007 +0100
Merge branch 'master' of ssh://git.freedesktop.org/git/hal
commit d314cab5b733d8340aa89d0ab40e4daa6eb3c689
Author: Sjoerd Simons <sjoerd at luon.net>
Date: Sun Nov 18 23:42:24 2007 +0100
assign pid to a gint64 before passing it as an _INT64 in a dbus message
This patch assigns a GPid to an gint64 before passing as a DBUS_TYPE_INT64 in a dbus message. Fixes alignment issues and ensures the correct size of the passed argument without the need to use __attribute__ ((aligned))
diff --git a/hald-runner/main.c b/hald-runner/main.c
index f767b9b..accb65d 100644
--- a/hald-runner/main.c
+++ b/hald-runner/main.c
@@ -137,7 +137,7 @@ handle_start(DBusConnection *con, DBusMessage *msg, gboolean is_singleton)
DBusMessage *reply;
DBusMessageIter iter;
run_request *r;
- GPid pid __attribute__ ((aligned));
+ GPid pid;
r = new_run_request();
r->is_singleton = is_singleton;
@@ -158,9 +158,10 @@ handle_start(DBusConnection *con, DBusMessage *msg, gboolean is_singleton)
}
if (run_request_run(r, con, NULL, &pid)) {
+ gint64 ppid = pid;
reply = dbus_message_new_method_return(msg);
dbus_message_append_args (reply,
- DBUS_TYPE_INT64, &pid,
+ DBUS_TYPE_INT64, &ppid,
DBUS_TYPE_INVALID);
} else {
diff --git a/hald-runner/runner.c b/hald-runner/runner.c
index cd6cf82..4847655 100644
--- a/hald-runner/runner.c
+++ b/hald-runner/runner.c
@@ -181,11 +181,12 @@ out:
/* emit a signal that this PID exited */
if(rd->con != NULL && rd->emit_pid_exited) {
DBusMessage *signal;
+ gint64 ppid = rd->pid;
signal = dbus_message_new_signal ("/org/freedesktop/HalRunner",
"org.freedesktop.HalRunner",
"StartedProcessExited");
dbus_message_append_args (signal,
- DBUS_TYPE_INT64, &(rd->pid),
+ DBUS_TYPE_INT64, &(ppid),
DBUS_TYPE_INVALID);
dbus_connection_send(rd->con, signal, NULL);
}
More information about the hal-commit
mailing list