[systemd-devel] Testing kdbus and bus-proxy

2015-07-01 Thread Daniel Buch
Hi,

I been testing kdbus (v4.1 branch) and bus-proxy on kernel v4.1 (arch
linux) and i just came across an inconsistency with my plain laptop/desktop
setup.

dleyna crashes as i start gnome-calendar.

Also calendar doesn't seem to run aswell, im not able to check my entries
(Not sure what's causing that)

However, all of that works on dbus-daemon.

Let me know if i can provide additional information.

jul 01 21:59:09 dbuch-laptop systemd[908]: Started DBUS1:
com.intel.dleyna-renderer.
jul 01 21:59:09 dbuch-laptop dleyna-renderer-service[1841]: Calling
GetRenderers method
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Type[0]
Level[0x13] Mask[0x4C] Flags[0x4F]
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Load file
[/home/dbuch/.config/dleyna-server-service.conf]
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: [General settings]
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Never Quit: F
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Connector Name:
dbus
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Port: 0
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Push host port: 0
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: [Logging settings]
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Log Type : 0
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Log Level: 0x13
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: [Network
filtering settings]
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Enabled : F
jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Entries: (null)
jul 01 21:59:09 dbuch-laptop systemd[908]: Started DBUS1:
com.intel.dleyna-server.
jul 01 21:59:09 dbuch-laptop bijiben-shell-search-provider[1701]:
(bijiben-shell-search-provider:1701): GLib-GObject-CRITICAL **:
g_object_unref: assertion 'G_IS_OBJECT (object)' failed
jul 01 21:59:09 dbuch-laptop gnome-calendar[1715]: **
(gnome-calendar:1715): WARNING **: Job failed: Operationen blev afbrudt
jul 01 21:59:09 dbuch-laptop dleyna-renderer-service[1841]: Client :1.6293
lost
jul 01 21:59:09 dbuch-laptop kernel: traps: dleyna-renderer[1841] general
protection ip:7fda14301338 sp:7ffcad8a9530 error:0 in
libdleyna-renderer-1.0.so.1.0.3[7fda142f7000+17000]
jul 01 21:59:09 dbuch-laptop systemd[908]:
dbus-com.intel.dleyna-renderer.service: Main process exited, code=dumped,
status=11/SEGV
jul 01 21:59:09 dbuch-laptop systemd[908]:
dbus-com.intel.dleyna-renderer.service: Unit entered failed state.
jul 01 21:59:09 dbuch-laptop systemd[908]:
dbus-com.intel.dleyna-renderer.service: Failed with result 'core-dump'.
jul 01 21:59:09 dbuch-laptop systemd-coredump[1875]: Removed old coredump
core.dleyna-renderer.1000.67c7a5ee3ae54363aba018379336bed6.1841.143578074900.lz4.
jul 01 21:59:09 dbuch-laptop systemd-coredump[1875]: Process 1841
(dleyna-renderer) of user 1000 dumped core.

 Stack trace of thread
1841:
 #0  0x7fda14301338
dlr_device_unsubscribe (libdleyna-renderer-1.0.so.1)
 #1  0x7fda14307cfa
dlr_upnp_unsubscribe (libdleyna-renderer-1.0.so.1)
 #2  0x7fda14305017
n/a (libdleyna-renderer-1.0.so.1)
 #3  0x7fda14820b62
n/a (libdleyna-core-1.0.so.4)
 #4  0x7fda1455890d
g_main_context_dispatch (libglib-2.0.so.0)
 #5  0x7fda14558ce0
n/a (libglib-2.0.so.0)
 #6  0x7fda14559002
g_main_loop_run (libglib-2.0.so.0)
 #7  0x7fda14820d3c
dleyna_main_loop_start (libdleyna-core-1.0.so.4)
 #8  0x7fda13d58790
__libc_start_main (libc.so.6)
 #9  0x004008e9
_start (dleyna-renderer-service)

 Stack trace of thread
1853:
 #0  0x7fda13e16e8d
poll (libc.so.6)
 #1  0x7fda14558c7c
n/a (libglib-2.0.so.0)
 #2  0x7fda14559002
g_main_loop_run (libglib-2.0.so.0)
 #3  0x7fda13a99876
n/a (libgio-2.0.so.0)
 #4  0x7fda1457f625
n/a (libglib-2.0.so.0)
 #5  0x7fda140e1354
start_thread (libpthread.so.0)
 #6  0x7fda13e1fbfd
__clone (libc.so.6)

 Stack trace of thread
1857:
   

Re: [systemd-devel] Testing kdbus and bus-proxy

2015-07-01 Thread Daniel Buch
Alright, i just updated kdbus branch, and these issues is solved..

ons. 1. jul. 2015 kl. 22.20 skrev Daniel Buch boogiewasth...@gmail.com:

 Hi,

 I been testing kdbus (v4.1 branch) and bus-proxy on kernel v4.1 (arch
 linux) and i just came across an inconsistency with my plain laptop/desktop
 setup.

 dleyna crashes as i start gnome-calendar.

 Also calendar doesn't seem to run aswell, im not able to check my entries
 (Not sure what's causing that)

 However, all of that works on dbus-daemon.

 Let me know if i can provide additional information.

 jul 01 21:59:09 dbuch-laptop systemd[908]: Started DBUS1:
 com.intel.dleyna-renderer.
 jul 01 21:59:09 dbuch-laptop dleyna-renderer-service[1841]: Calling
 GetRenderers method
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Type[0]
 Level[0x13] Mask[0x4C] Flags[0x4F]
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Load file
 [/home/dbuch/.config/dleyna-server-service.conf]
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: [General
 settings]
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Never Quit: F
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Connector Name:
 dbus
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Port: 0
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Push host port: 0
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: [Logging
 settings]
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Log Type : 0
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Log Level: 0x13
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: [Network
 filtering settings]
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Enabled : F
 jul 01 21:59:09 dbuch-laptop dleyna-server-service[1854]: Entries: (null)
 jul 01 21:59:09 dbuch-laptop systemd[908]: Started DBUS1:
 com.intel.dleyna-server.
 jul 01 21:59:09 dbuch-laptop bijiben-shell-search-provider[1701]:
 (bijiben-shell-search-provider:1701): GLib-GObject-CRITICAL **:
 g_object_unref: assertion 'G_IS_OBJECT (object)' failed
 jul 01 21:59:09 dbuch-laptop gnome-calendar[1715]: **
 (gnome-calendar:1715): WARNING **: Job failed: Operationen blev afbrudt
 jul 01 21:59:09 dbuch-laptop dleyna-renderer-service[1841]: Client :1.6293
 lost
 jul 01 21:59:09 dbuch-laptop kernel: traps: dleyna-renderer[1841] general
 protection ip:7fda14301338 sp:7ffcad8a9530 error:0 in
 libdleyna-renderer-1.0.so.1.0.3[7fda142f7000+17000]
 jul 01 21:59:09 dbuch-laptop systemd[908]:
 dbus-com.intel.dleyna-renderer.service: Main process exited, code=dumped,
 status=11/SEGV
 jul 01 21:59:09 dbuch-laptop systemd[908]:
 dbus-com.intel.dleyna-renderer.service: Unit entered failed state.
 jul 01 21:59:09 dbuch-laptop systemd[908]:
 dbus-com.intel.dleyna-renderer.service: Failed with result 'core-dump'.
 jul 01 21:59:09 dbuch-laptop systemd-coredump[1875]: Removed old coredump
 core.dleyna-renderer.1000.67c7a5ee3ae54363aba018379336bed6.1841.143578074900.lz4.
 jul 01 21:59:09 dbuch-laptop systemd-coredump[1875]: Process 1841
 (dleyna-renderer) of user 1000 dumped core.

  Stack trace of thread
 1841:
  #0
  0x7fda14301338 dlr_device_unsubscribe (libdleyna-renderer-1.0.so.1)
  #1
  0x7fda14307cfa dlr_upnp_unsubscribe (libdleyna-renderer-1.0.so.1)
  #2
  0x7fda14305017 n/a (libdleyna-renderer-1.0.so.1)
  #3
  0x7fda14820b62 n/a (libdleyna-core-1.0.so.4)
  #4
  0x7fda1455890d g_main_context_dispatch (libglib-2.0.so.0)
  #5
  0x7fda14558ce0 n/a (libglib-2.0.so.0)
  #6
  0x7fda14559002 g_main_loop_run (libglib-2.0.so.0)
  #7
  0x7fda14820d3c dleyna_main_loop_start (libdleyna-core-1.0.so.4)
  #8
  0x7fda13d58790 __libc_start_main (libc.so.6)
  #9
  0x004008e9 _start (dleyna-renderer-service)

  Stack trace of thread
 1853:
  #0
  0x7fda13e16e8d poll (libc.so.6)
  #1
  0x7fda14558c7c n/a (libglib-2.0.so.0)
  #2
  0x7fda14559002 g_main_loop_run (libglib-2.0.so.0)
  #3
  0x7fda13a99876 n/a (libgio-2.0.so.0)
  #4
  0x7fda1457f625 n/a (libglib-2.0.so.0)
  #5

[systemd-devel] PATCH: systemctl: null-initialize pointer with cleanup attribute

2015-05-06 Thread Daniel Buch
Patch attached. (git send-email currently brokken)

declarations with _cleanup_free_ attribute needs to be NULL initialized.
From e242049410bb8373f8724ac24328e0f024b9929b Mon Sep 17 00:00:00 2001
From: Daniel Buch boogiewasth...@gmail.com
Date: Wed, 6 May 2015 10:28:08 +0200
Subject: [PATCH] systemctl: null-initialize pointer with cleanup attribute

---
 src/systemctl/systemctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 4f36ba8..4c45bfc 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -7289,7 +7289,7 @@ static int halt_main(sd_bus *bus) {
 if (arg_when  0) {
 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
 _cleanup_bus_close_unref_ sd_bus *b = NULL;
-_cleanup_free_ char *m;
+_cleanup_free_ char *m = NULL;
 
 if (avoid_bus()) {
 log_error(Unable to perform operation without bus connection.);
-- 
2.4.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] journal-.gitignore-add-audit_type-from-name

2015-04-30 Thread Daniel Buch

From 785b1367fedb912e91074360c0961209ac5dc9f8 Mon Sep 17 00:00:00 2001
From: Daniel Buch boogiewasth...@gmail.com
Date: Thu, 30 Apr 2015 21:20:57 +0200
Subject: [PATCH] journal: .gitignore add audit_type-from-name*

---
 src/journal/.gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/journal/.gitignore b/src/journal/.gitignore
index 0f094f5..94adfb3 100644
--- a/src/journal/.gitignore
+++ b/src/journal/.gitignore
@@ -2,3 +2,5 @@
 /libsystemd-journal.pc
 /audit_type-list.txt
 /audit_type-to-name.h
+/audit_type-from-name.h
+/audit_type-from-name.gperf
-- 
2.3.7

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] avahi disconnects from bus with kdbus

2015-02-15 Thread Daniel Buch
Hi, I can confirm it works. Also I haven't noticed any complaints in the
journal. Good luck with v4.

lør. 14. feb. 2015 18.10 skrev David Herrmann dh.herrm...@gmail.com:

 Hi Daniel!

 On Fri, Feb 13, 2015 at 1:16 PM, David Herrmann dh.herrm...@gmail.com
 wrote:
  Hi
 
  On Thu, Feb 12, 2015 at 11:32 PM, Daniel Buch boogiewasth...@gmail.com
 wrote:
  Hi again,
 
  I found another problem, again with avahi-daemon but in combination with
  Telepathy haze.
  feb 13 08:26:39 dbuch-laptop systemd-coredump[1211]: Process 1167
  (telepathy-haze) of user 1000 dumped core.
 
   Stack trace of
 thread
  1167:
   #0
 0x7fe0c9557ae0
  g_logv (libglib-2.0.so.0)
   #1
 0x7fe0c9557d1f
  g_log (libglib-2.0.so.0)
   #2
 0x0041261c
  n/a (telepathy-haze)
   #3
 0x7fe0c955091d
  g_main_context_dispatch (libglib-2.0.so.0)
   #4
 0x7fe0c9550cf8
  n/a (libglib-2.0.so.0)
   #5
 0x7fe0c9551022
  g_main_loop_run (libglib-2.0.so.0)
   #6
 0x7fe0c9214631
  tp_run_connection_manager (libtelepathy-glib.so.0)
   #7
 0x0040e73b
  n/a (telepathy-haze)
   #8
 0x7fe0c8b1e800
  __libc_start_main (libc.so.6)
   #9
 0x0040e7ad
  n/a (telepathy-haze)
 
  This looks like a bug in telepathy, properly triggered by a dbus
  error. This should be fixed upstream, but..
 
  feb 13 08:26:42 dbuch-laptop systemd[642]: Starting DBUS1:
  org.freedesktop.Telepathy.ConnectionManager.haze...
  feb 13 08:26:42 dbuch-laptop systemd[642]: Started DBUS1:
  org.freedesktop.Telepathy.ConnectionManager.haze.
  feb 13 08:26:42 dbuch-laptop systemd[1]: Starting Avahi mDNS/DNS-SD
 Stack...
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Found user 'avahi'
 (UID 84)
  and group 'avahi' (GID 84).
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Successfully dropped
 root
  privileges.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: avahi-daemon 0.6.31
  starting up.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Successfully called
  chroot().
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Successfully dropped
  remaining capabilities.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Loading service file
  /services/sftp-ssh.service.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Process 313 died: No
 such
  process; trying to remove PID file. (/var/run/avahi-daemon//pid)
  feb 13 08:26:42 dbuch-laptop systemd[1]: Started Avahi mDNS/DNS-SD
 Stack.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Loading service file
  /services/ssh.service.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Joining mDNS multicast
  group on interface wlp3s0.IPv4 with address 192.168.1.2.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: New relevant interface
  wlp3s0.IPv4 for mDNS.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Network interface
  enumeration completed.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Registering new address
  record for fe80::eab1:fcff:fec4:eae1 on wlp3s0.*.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Registering new address
  record for 192.168.1.2 on wlp3s0.IPv4.
  feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Registering HINFO
 record
  with values 'X86_64'/'LINUX'.
  feb 13 08:26:42 dbuch-laptop systemd-bus-proxyd[329]: Failed to send
 message
  to bus: Operation not permitted
 
  ..this might be what triggered it. It'd be interesting to see which
  message was refused here. I'll see whether we can make the bus-proxy
  more verbose on EPERM.

 This issue should be fixed with systemd-git and kdbus-git:
  - systemd-bus-proxyd no longer closes the connection on EPERM, but
 forwards the error
  - kdbus no longer generates EPERM for unicast-signals

 The bus-proxyd fix should make sure that avahi continues running, the
 kdbus fix should make sure that EPERM is no longer generated for
 avahi.

 Thanks
 David

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] avahi disconnects from bus with kdbus

2015-02-12 Thread Daniel Buch
No problem, i will try do some extensive testing the next couple of days.
kdbus is now added to kernel entry cmdline :)

2015-02-12 19:12 GMT+01:00 David Herrmann dh.herrm...@gmail.com:

 Hi

 On Wed, Feb 11, 2015 at 11:17 AM, Daniel Buch boogiewasth...@gmail.com
 wrote:
  Nice, everything works flawlessly with current git now. Good job!

 Thanks for testing! No idea which commit exactly fixed it, so if you
 see it again, please let us know.

 Thanks
 David

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] avahi disconnects from bus with kdbus

2015-02-12 Thread Daniel Buch
Hi again,

I found another problem, again with avahi-daemon but in combination with
Telepathy haze.
feb 13 08:26:39 dbuch-laptop systemd-coredump[1211]: Process 1167
(telepathy-haze) of user 1000 dumped core.

 Stack trace of thread
1167:
 #0  0x7fe0c9557ae0
g_logv (libglib-2.0.so.0)
 #1  0x7fe0c9557d1f
g_log (libglib-2.0.so.0)
 #2  0x0041261c
n/a (telepathy-haze)
 #3  0x7fe0c955091d
g_main_context_dispatch (libglib-2.0.so.0)
 #4  0x7fe0c9550cf8
n/a (libglib-2.0.so.0)
 #5  0x7fe0c9551022
g_main_loop_run (libglib-2.0.so.0)
 #6  0x7fe0c9214631
tp_run_connection_manager (libtelepathy-glib.so.0)
 #7  0x0040e73b
n/a (telepathy-haze)
 #8  0x7fe0c8b1e800
__libc_start_main (libc.so.6)
 #9  0x0040e7ad
n/a (telepathy-haze)
feb 13 08:26:42 dbuch-laptop systemd[642]: Starting DBUS1:
org.freedesktop.Telepathy.ConnectionManager.haze...
feb 13 08:26:42 dbuch-laptop systemd[642]: Started DBUS1:
org.freedesktop.Telepathy.ConnectionManager.haze.
feb 13 08:26:42 dbuch-laptop systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Found user 'avahi' (UID
84) and group 'avahi' (GID 84).
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Successfully dropped root
privileges.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: avahi-daemon 0.6.31
starting up.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Successfully called
chroot().
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Successfully dropped
remaining capabilities.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Loading service file
/services/sftp-ssh.service.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Process 313 died: No such
process; trying to remove PID file. (/var/run/avahi-daemon//pid)
feb 13 08:26:42 dbuch-laptop systemd[1]: Started Avahi mDNS/DNS-SD Stack.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Loading service file
/services/ssh.service.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Joining mDNS multicast
group on interface wlp3s0.IPv4 with address 192.168.1.2.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: New relevant interface
wlp3s0.IPv4 for mDNS.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Network interface
enumeration completed.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Registering new address
record for fe80::eab1:fcff:fec4:eae1 on wlp3s0.*.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Registering new address
record for 192.168.1.2 on wlp3s0.IPv4.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Registering HINFO record
with values 'X86_64'/'LINUX'.
feb 13 08:26:42 dbuch-laptop systemd-bus-proxyd[329]: Failed to send
message to bus: Operation not permitted
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Disconnected from D-Bus,
exiting.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Got SIGTERM, quitting.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: Leaving mDNS multicast
group on interface wlp3s0.IPv4 with address 192.168.1.2.
feb 13 08:26:42 dbuch-laptop avahi-daemon[1217]: avahi-daemon 0.6.31
exiting.

This happens when you try to log on empathy, more specifically Peoples
Nearby.

Let me know if you want additional logs or anything.

Cheers,
Daniel

2015-02-12 23:46 GMT+01:00 Daniel Buch boogiewasth...@gmail.com:

 No problem, i will try do some extensive testing the next couple of days.
 kdbus is now added to kernel entry cmdline :)

 2015-02-12 19:12 GMT+01:00 David Herrmann dh.herrm...@gmail.com:

 Hi

 On Wed, Feb 11, 2015 at 11:17 AM, Daniel Buch boogiewasth...@gmail.com
 wrote:
  Nice, everything works flawlessly with current git now. Good job!

 Thanks for testing! No idea which commit exactly fixed it, so if you
 see it again, please let us know.

 Thanks
 David



___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] avahi disconnects from bus with kdbus

2015-02-11 Thread Daniel Buch
Nice, everything works flawlessly with current git now. Good job!

2015-02-10 10:34 GMT+01:00 Daniel Buch boogiewasth...@gmail.com:

 Hi,

 This is just a heads up.

 Avahi-daemon doesn't work on my system with kdbus and bus-proxyd. I
 appended a log. I hope this helps. Otherwise every thing works quite well
 for me with current systemd,kdbus git.

 feb 10 10:11:12 dbuch-laptop avahi-daemon[2561]: avahi-daemon 0.6.31
 exiting.
 feb 10 10:11:37 dbuch-laptop systemd[1]: Starting Avahi mDNS/DNS-SD
 Stack...
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Found user 'avahi' (UID
 84) and group 'avahi' (GID 84).
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Successfully dropped root
 privileges.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: avahi-daemon 0.6.31
 starting up.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Successfully called
 chroot().
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Successfully dropped
 remaining capabilities.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Loading service file
 /services/sftp-ssh.service.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Loading service file
 /services/ssh.service.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Joining mDNS multicast
 group on interface wlp3s0.IPv4 with address 192.168.1.3.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: New relevant interface
 wlp3s0.IPv4 for mDNS.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Network interface
 enumeration completed.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Registering new address
 record for 192.168.1.3 on wlp3s0.IPv4.
 feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Registering HINFO record
 with values 'X86_64'/'LINUX'.
 feb 10 10:11:37 dbuch-laptop systemd[1]: Started Avahi mDNS/DNS-SD Stack.
 feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: Server startup complete.
 Host name is dbuch-laptop.local. Local service cookie is 234317167
 feb 10 10:11:38 dbuch-laptop systemd-bus-proxyd[1783]: Failed to send
 message to bus: Operation not permitted
 feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: Disconnected from D-Bus,
 exiting.
 feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: Got SIGTERM, quitting.
 feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: Leaving mDNS multicast
 group on interface wlp3s0.IPv4 with address 192.168.1.3.
 feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: avahi-daemon 0.6.31
 exiting.


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] avahi disconnects from bus with kdbus

2015-02-10 Thread Daniel Buch
Hi,

This is just a heads up.

Avahi-daemon doesn't work on my system with kdbus and bus-proxyd. I
appended a log. I hope this helps. Otherwise every thing works quite well
for me with current systemd,kdbus git.

feb 10 10:11:12 dbuch-laptop avahi-daemon[2561]: avahi-daemon 0.6.31
exiting.
feb 10 10:11:37 dbuch-laptop systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Found user 'avahi' (UID
84) and group 'avahi' (GID 84).
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Successfully dropped root
privileges.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: avahi-daemon 0.6.31
starting up.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Successfully called
chroot().
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Successfully dropped
remaining capabilities.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Loading service file
/services/sftp-ssh.service.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Loading service file
/services/ssh.service.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Joining mDNS multicast
group on interface wlp3s0.IPv4 with address 192.168.1.3.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: New relevant interface
wlp3s0.IPv4 for mDNS.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Network interface
enumeration completed.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Registering new address
record for 192.168.1.3 on wlp3s0.IPv4.
feb 10 10:11:37 dbuch-laptop avahi-daemon[2582]: Registering HINFO record
with values 'X86_64'/'LINUX'.
feb 10 10:11:37 dbuch-laptop systemd[1]: Started Avahi mDNS/DNS-SD Stack.
feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: Server startup complete.
Host name is dbuch-laptop.local. Local service cookie is 234317167
feb 10 10:11:38 dbuch-laptop systemd-bus-proxyd[1783]: Failed to send
message to bus: Operation not permitted
feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: Disconnected from D-Bus,
exiting.
feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: Got SIGTERM, quitting.
feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: Leaving mDNS multicast
group on interface wlp3s0.IPv4 with address 192.168.1.3.
feb 10 10:11:38 dbuch-laptop avahi-daemon[2582]: avahi-daemon 0.6.31
exiting.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] test-capabilities fail and systemd-timesyncd broken

2015-02-04 Thread Daniel Buch
Okay, Tom fixed this with 057255fbbf2ecb1c46e025b04087fa9340d9880d.

2015-02-03 21:50 GMT+01:00 Daniel Buch boogiewasth...@gmail.com:

 Hi,

 This commit 51ddf61540976fc7b09ce5 solved systemd-resolved, but broke
 systemd-timesyncd. Atleast on my system.

 dbuch@dbuch-laptop ~ % lscpu | grep -i byte
 Byte Order:Little Endian

 dbuch@dbuch-laptop ~ % SYSTEMD_LOGLEVEL=debug sudo
 /usr/lib/systemd/systemd-timesyncd
 Failed to enable capabilities bits: Invalid argument

 I suspect the usage of log2u64() is wrong? Im not able to gork this, but
 hope this helps :)

 Kind regards, Daniel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] test-capabilities fail and systemd-timesyncd broken

2015-02-03 Thread Daniel Buch
Hi,

This commit 51ddf61540976fc7b09ce5 solved systemd-resolved, but broke
systemd-timesyncd. Atleast on my system.

dbuch@dbuch-laptop ~ % lscpu | grep -i byte
Byte Order:Little Endian

dbuch@dbuch-laptop ~ % SYSTEMD_LOGLEVEL=debug sudo
/usr/lib/systemd/systemd-timesyncd
Failed to enable capabilities bits: Invalid argument

I suspect the usage of log2u64() is wrong? Im not able to gork this, but
hope this helps :)

Kind regards, Daniel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] switch_root: do not fail, if base_filesystem_create() failed

2014-11-04 Thread Daniel Buch
I think you might want to cast it to avoid compiler warning. Like:
(void) base_filesystem_create()
Den 04/11/2014 17.36 skrev har...@redhat.com:

 From: Harald Hoyer har...@redhat.com

 Not all switch roots are like base_filesystem_create() wants them
 to look like. They might even boot, if they are RO and don't have the FS
 layout. Just ignore the error and switch_root nevertheless.

 base_filesystem_create() should have logged, what went wrong.
 ---
  src/shared/switch-root.c | 6 +-
  1 file changed, 1 insertion(+), 5 deletions(-)

 diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c
 index bac0e5c..673f8a7 100644
 --- a/src/shared/switch-root.c
 +++ b/src/shared/switch-root.c
 @@ -103,11 +103,7 @@ int switch_root(const char *new_root, const char
 *oldroot, bool detach_oldroot,
  }
  }

 -r = base_filesystem_create(new_root);
 -if (r  0) {
 -log_error(Failed to create the base filesystem: %s,
 strerror(-r));
 -return r;
 -}
 +base_filesystem_create(new_root);

  if (chdir(new_root)  0) {
  log_error(Failed to change directory to %s: %m,
 new_root);
 --
 2.1.0

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] sysusers.c: make use of negative_errno()

2014-11-04 Thread Daniel Buch
This is recently added by david. And i like replace return -errno treewide if 
desired?

I suppose its safe and correct to assume every return -errno can be replaced?

---
 src/sysusers/sysusers.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index c133dc5..11624ad 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -143,7 +143,7 @@ static int load_user_database(void) {
 errno = 0;
 }
 if (!IN_SET(errno, 0, ENOENT))
-return -errno;
+return negative_errno();
 
 return 0;
 }
@@ -195,7 +195,7 @@ static int load_group_database(void) {
 errno = 0;
 }
 if (!IN_SET(errno, 0, ENOENT))
-return -errno;
+return negative_errno();
 
 return 0;
 }
@@ -213,11 +213,11 @@ static int make_backup(const char *target, const char *x) 
{
 if (errno == ENOENT) /* No backup necessary... */
 return 0;
 
-return -errno;
+return negative_errno();
 }
 
 if (fstat(src, st)  0)
-return -errno;
+return negative_errno();
 
 r = fopen_temporary_label(target, x, dst, temp);
 if (r  0)
@@ -790,7 +790,7 @@ static int uid_is_ok(uid_t uid, const char *name) {
 if (p)
 return 0;
 if (!IN_SET(errno, 0, ENOENT))
-return -errno;
+return negative_errno();
 
 errno = 0;
 g = getgrgid((gid_t) uid);
@@ -798,7 +798,7 @@ static int uid_is_ok(uid_t uid, const char *name) {
 if (!streq(g-gr_name, name))
 return 0;
 } else if (!IN_SET(errno, 0, ENOENT))
-return -errno;
+return negative_errno();
 }
 
 return 1;
@@ -809,7 +809,7 @@ static int root_stat(const char *p, struct stat *st) {
 
 fix = fix_root(p);
 if (stat(fix, st)  0)
-return -errno;
+return negative_errno();
 
 return 0;
 }
@@ -905,7 +905,7 @@ static int add_user(Item *i) {
 }
 if (!IN_SET(errno, 0, ENOENT)) {
 log_error(Failed to check if user %s already exists: 
%m, i-name);
-return -errno;
+return negative_errno();
 }
 
 /* And shadow too, just to be sure */
@@ -917,7 +917,7 @@ static int add_user(Item *i) {
 }
 if (!IN_SET(errno, 0, ENOENT)) {
 log_error(Failed to check if user %s already exists 
in shadow database: %m, i-name);
-return -errno;
+return negative_errno();
 }
 }
 
@@ -1027,14 +1027,14 @@ static int gid_is_ok(gid_t gid) {
 if (g)
 return 0;
 if (!IN_SET(errno, 0, ENOENT))
-return -errno;
+return negative_errno();
 
 errno = 0;
 p = getpwuid((uid_t) gid);
 if (p)
 return 0;
 if (!IN_SET(errno, 0, ENOENT))
-return -errno;
+return negative_errno();
 }
 
 return 1;
@@ -1069,7 +1069,7 @@ static int add_group(Item *i) {
 }
 if (!IN_SET(errno, 0, ENOENT)) {
 log_error(Failed to check if group %s already exists: 
%m, i-name);
-return -errno;
+return negative_errno();
 }
 }
 
-- 
2.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] sysusers.c: make use of negative_errno()

2014-11-04 Thread Daniel Buch
Nevermind, ignore this. This is of course only where gcc complaints.
Den 04/11/2014 20.53 skrev Daniel Buch boogiewasth...@gmail.com:

 This is recently added by david. And i like replace return -errno treewide
 if desired?

 I suppose its safe and correct to assume every return -errno can be
 replaced?

 ---
  src/sysusers/sysusers.c | 24 
  1 file changed, 12 insertions(+), 12 deletions(-)

 diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
 index c133dc5..11624ad 100644
 --- a/src/sysusers/sysusers.c
 +++ b/src/sysusers/sysusers.c
 @@ -143,7 +143,7 @@ static int load_user_database(void) {
  errno = 0;
  }
  if (!IN_SET(errno, 0, ENOENT))
 -return -errno;
 +return negative_errno();

  return 0;
  }
 @@ -195,7 +195,7 @@ static int load_group_database(void) {
  errno = 0;
  }
  if (!IN_SET(errno, 0, ENOENT))
 -return -errno;
 +return negative_errno();

  return 0;
  }
 @@ -213,11 +213,11 @@ static int make_backup(const char *target, const
 char *x) {
  if (errno == ENOENT) /* No backup necessary... */
  return 0;

 -return -errno;
 +return negative_errno();
  }

  if (fstat(src, st)  0)
 -return -errno;
 +return negative_errno();

  r = fopen_temporary_label(target, x, dst, temp);
  if (r  0)
 @@ -790,7 +790,7 @@ static int uid_is_ok(uid_t uid, const char *name) {
  if (p)
  return 0;
  if (!IN_SET(errno, 0, ENOENT))
 -return -errno;
 +return negative_errno();

  errno = 0;
  g = getgrgid((gid_t) uid);
 @@ -798,7 +798,7 @@ static int uid_is_ok(uid_t uid, const char *name) {
  if (!streq(g-gr_name, name))
  return 0;
  } else if (!IN_SET(errno, 0, ENOENT))
 -return -errno;
 +return negative_errno();
  }

  return 1;
 @@ -809,7 +809,7 @@ static int root_stat(const char *p, struct stat *st) {

  fix = fix_root(p);
  if (stat(fix, st)  0)
 -return -errno;
 +return negative_errno();

  return 0;
  }
 @@ -905,7 +905,7 @@ static int add_user(Item *i) {
  }
  if (!IN_SET(errno, 0, ENOENT)) {
  log_error(Failed to check if user %s already
 exists: %m, i-name);
 -return -errno;
 +return negative_errno();
  }

  /* And shadow too, just to be sure */
 @@ -917,7 +917,7 @@ static int add_user(Item *i) {
  }
  if (!IN_SET(errno, 0, ENOENT)) {
  log_error(Failed to check if user %s already
 exists in shadow database: %m, i-name);
 -return -errno;
 +return negative_errno();
  }
  }

 @@ -1027,14 +1027,14 @@ static int gid_is_ok(gid_t gid) {
  if (g)
  return 0;
  if (!IN_SET(errno, 0, ENOENT))
 -return -errno;
 +return negative_errno();

  errno = 0;
  p = getpwuid((uid_t) gid);
  if (p)
  return 0;
  if (!IN_SET(errno, 0, ENOENT))
 -return -errno;
 +return negative_errno();
  }

  return 1;
 @@ -1069,7 +1069,7 @@ static int add_group(Item *i) {
  }
  if (!IN_SET(errno, 0, ENOENT)) {
  log_error(Failed to check if group %s already
 exists: %m, i-name);
 -return -errno;
 +return negative_errno();
  }
  }

 --
 2.1.3


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] systemctl: add edit verb

2014-10-14 Thread Daniel Buch
My general understanding is equal to dale. But with some consideration it
led me to agree with the warning approach. Its no big deal setting EDITOR.
Den 14/10/2014 01.06 skrev Ronny Chevalier chevalier.ro...@gmail.com:

 2014-10-13 16:13 GMT+02:00 Simon McVittie simon.mcvit...@collabora.co.uk
 :
  On 13/10/14 14:38, Dale R. Worley wrote:
  My general understanding is that the traditional behavior when you
  need an editor but the user hasn't specified one is to use vi, and
  so people who don't want vi *always* set $VISUAL in their
  environment.
 
  The Right Thing™ is distro-specific. Debian and its derivatives have
  sensible-editor(1) which is a shell script that uses $VISUAL, $EDITOR,
  nano[1] or vi; I would expect systemd in Debian to use sensible-editor
  as its fallback, either via a configure option or a patch.
 
  In distros without sensible-editor, I'm tempted to say the solution is
  stop being a distro without sensible-editor. New systemd API? :-)
 
 Before I resend the patch, we should agree on what to do here, for me
 it makes more sense to raise an error asking to set either EDITOR or
 SYSTEMD_EDITOR than running vi or a sensible-editor like you said.
 Because, someone used to its editor will quit vi or sensible-editor
 and will try to find out how to set the editor for systemctl (Even if
 it is well known for EDITOR or VISUAL, some people don't set these
 variables).

 If we raise an error, someone not used to these variables but having a
 favorite editor will know how to change this. And if this person does
 not have a favorite editor and never used one (unlikely but I think
 this is the purpose of the sensible-editor ?), we can advice to set
 EDITOR to nano or an equivalent.
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] systemctl: add edit verb

2014-10-11 Thread Daniel Buch
Nice, I was in the process of implementing this. Looks good to me. But I
think it would be better to use vi instead of vim if no editor is set.
Vim is not installed on every system as default but vi is most likely.
Den 11/10/2014 18.37 skrev Ronny Chevalier chevalier.ro...@gmail.com:

 It helps editing units by either creating a drop-in file, like
 /etc/systemd/system/my.service.d/amendments.conf, or by copying the
 original unit from /usr/lib/systemd/ to /etc/systemd/ if the --full
 option is specified. Then it invokes the $SYSTEMD_EDITOR or $EDITOR or
 vim to the related files and daemon-reload is invoked when the editor
 exited
 successfully.

 See https://bugzilla.redhat.com/show_bug.cgi?id=906824
 ---
  TODO  |   2 -
  man/journalctl.xml|   6 +-
  man/less-variables.xml|  40 +++---
  man/localectl.xml |   6 +-
  man/loginctl.xml  |   6 +-
  man/machinectl.xml|   6 +-
  man/systemctl.xml |  44 +-
  man/systemd-analyze.xml   |   6 +-
  man/timedatectl.xml   |   6 +-
  src/systemctl/systemctl.c | 346
 +-
  10 files changed, 435 insertions(+), 33 deletions(-)

 diff --git a/TODO b/TODO
 index 0aaa9f2..857bdd0 100644
 --- a/TODO
 +++ b/TODO
 @@ -65,8 +65,6 @@ Features:

  * systemctl: if it fails, show log output?

 -* maybe add systemctl edit that copies unit files from
 /usr/lib/systemd/system to /etc/systemd/system and invokes vim on them
 -
  * dbus: add new message hdr field for allowing interactive auth, write
 spec for it. update dbus spec to mandate that unknown flags *must* be
 ignored...

  * maybe introduce AssertXYZ= similar to ConditionXYZ= that causes a unit
 to fail (instead of skipping it) if some condition is not true...
 diff --git a/man/journalctl.xml b/man/journalctl.xml
 index 7fb6afc..d36889f 100644
 --- a/man/journalctl.xml
 +++ b/man/journalctl.xml
 @@ -891,7 +891,11 @@
  failure code is returned./para
  /refsect1

 -xi:include href=less-variables.xml /
 +refsect1
 +titleEnvironment/title
 +
 +xi:include href=less-variables.xml /
 +/refsect1

  refsect1
  titleExamples/title
 diff --git a/man/less-variables.xml b/man/less-variables.xml
 index 09cbd42..1b8aae0 100644
 --- a/man/less-variables.xml
 +++ b/man/less-variables.xml
 @@ -2,28 +2,24 @@
  !DOCTYPE book PUBLIC -//OASIS//DTD DocBook XML V4.5//EN
   http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd
 

 -refsect1
 -titleEnvironment/title
 +variablelist class='environment-variables'
 +   varlistentry
 +   termvarname$SYSTEMD_PAGER/varname/term

 -variablelist class='environment-variables'
 -varlistentry
 -termvarname$SYSTEMD_PAGER/varname/term
 +   listitemparaPager to use when
 +   option--no-pager/option is not given;
 +   overrides varname$PAGER/varname.  Setting
 +   this to an empty string or the value
 +   literalcat/literal is equivalent to passing
 +   option--no-pager/option./para/listitem
 +   /varlistentry

 -listitemparaPager to use when
 -option--no-pager/option is not given;
 -overrides varname$PAGER/varname.  Setting
 -this to an empty string or the value
 -literalcat/literal is equivalent to passing
 -option--no-pager/option./para/listitem
 -/varlistentry
 +   varlistentry
 +   termvarname$SYSTEMD_LESS/varname/term

 -varlistentry
 -termvarname$SYSTEMD_LESS/varname/term
 -
 -listitemparaOverride the default
 -options passed to
 -commandless/command
 -(literalFRSXMK/literal)./para/listitem
 -/varlistentry
 -/variablelist
 -/refsect1
 +   listitemparaOverride the default
 +   options passed to
 +   commandless/command
 +   (literalFRSXMK/literal)./para/listitem
 +   /varlistentry
 +/variablelist
 diff --git a/man/localectl.xml b/man/localectl.xml
 index 38e73c7..7ae6c60 100644
 --- a/man/localectl.xml
 +++ b/man/localectl.xml
 @@ -223,7 +223,11 @@
  code otherwise./para
  /refsect1

 -xi:include href=less-variables.xml /
 +refsect1
 +titleEnvironment/title
 +
 +xi:include href=less-variables.xml /
 +/refsect1

  refsect1
  titleSee Also/title
 diff --git a/man/loginctl.xml b/man/loginctl.xml
 index 749db92..4754790 100644
 --- a/man/loginctl.xml
 +++ b/man/loginctl.xml
 @@ -438,7 +438,11 @@
  code otherwise./para
  /refsect1

 - 

Re: [systemd-devel] [Question/bug] Timeout after bus_event_loop_with_idle() change.

2014-10-09 Thread Daniel Buch
No runtime kdbus but --enable-kdbus configuration at build time
Den 08/10/2014 17.11 skrev Lennart Poettering lenn...@poettering.net:

 On Fri, 03.10.14 22:00, Daniel Buch (boogiewasth...@gmail.com) wrote:

  Hi,
 
  With current git and since 430e21c2f7e77d600257ead56419f51 i keep on
  getting timeout on these units
 
  dbuch@dbuch-laptop ~/dev/systemd (git)-[master] % systemctl --failed
UNIT  LOAD   ACTIVE SUBDESCRIPTION
  ● systemd-hostnamed.service loaded failed failed Hostname Service
  ● systemd-localed.service   loaded failed failed Locale Service
  ● systemd-timedated.service loaded failed failed Time  Date Service
 
 
  My build config looks like this:
--libexecdir=/usr/lib \
--localstatedir=/var \
--sysconfdir=/etc \
--enable-introspection \
--enable-gtk-doc \
--enable-kdbus \
--enable-compat-libs \
--enable-timesyncd \
--enable-lz4 \
--enable-terminal \
--enable-resolved \
--disable-audit \
--disable-ima \
--disable-multi-seat-x \
--disable-smack \
--with-sysvinit-path= \
--with-sysvrcnd-path= \
--with-firmware-path=/usr/lib/firmware/updates:/usr/lib/firmware
 \
 
 
  Am i missing something? I havn't yet found any solution yet, and journal
  isn't helping me much here.

 Is this with kdbus enabled (in systemd, kernel, runtime)?

 Lennart

 --
 Lennart Poettering, Red Hat

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [Question/bug] Timeout after bus_event_loop_with_idle() change.

2014-10-09 Thread Daniel Buch
Cool, seems fixed.

okt 09 19:18:34 dbuch-laptop systemd[1]: Starting Hostname Service...
okt 09 19:18:34 dbuch-laptop systemd[1]: Started Hostname Service.
okt 09 19:20:34 dbuch-laptop systemd[1]: systemd-hostnamed.service stopping
timed out. Terminating.
okt 09 19:20:34 dbuch-laptop systemd[1]: Unit systemd-hostnamed.service
entered failed state.
okt 09 19:20:34 dbuch-laptop systemd[1]: systemd-hostnamed.service failed.
okt 09 19:20:57 dbuch-laptop systemd[1]: Starting Hostname Service...
okt 09 19:20:57 dbuch-laptop systemd[1]: Started Hostname Service.
okt 09 19:22:57 dbuch-laptop systemd[1]: systemd-hostnamed.service stopping
timed out. Terminating.
okt 09 19:22:57 dbuch-laptop systemd[1]: Unit systemd-hostnamed.service
entered failed state.
okt 09 19:22:57 dbuch-laptop systemd[1]: systemd-hostnamed.service failed.
-- Reboot --
okt 09 19:49:34 dbuch-laptop systemd[1]: Starting Hostname Service...
okt 09 19:49:34 dbuch-laptop systemd[1]: Started Hostname Service.
dbuch@dbuch-laptop ~ % date
tor okt  9 19:55:13 CEST 2014
dbuch@dbuch-laptop ~ % systemctl --failed
0 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

They used to timeout after 2 minutes so this looks promising.

2014-10-09 18:23 GMT+02:00 Lennart Poettering lenn...@poettering.net:

 On Fri, 03.10.14 22:00, Daniel Buch (boogiewasth...@gmail.com) wrote:

  Hi,
 
  With current git and since 430e21c2f7e77d600257ead56419f51 i keep on
  getting timeout on these units
 
  dbuch@dbuch-laptop ~/dev/systemd (git)-[master] % systemctl --failed
UNIT  LOAD   ACTIVE SUBDESCRIPTION
  ● systemd-hostnamed.service loaded failed failed Hostname Service
  ● systemd-localed.service   loaded failed failed Locale Service
  ● systemd-timedated.service loaded failed failed Time  Date Service
 
 
  My build config looks like this:
--libexecdir=/usr/lib \
--localstatedir=/var \
--sysconfdir=/etc \
--enable-introspection \
--enable-gtk-doc \
--enable-kdbus \
--enable-compat-libs \
--enable-timesyncd \
--enable-lz4 \
--enable-terminal \
--enable-resolved \
--disable-audit \
--disable-ima \
--disable-multi-seat-x \
--disable-smack \
--with-sysvinit-path= \
--with-sysvrcnd-path= \
--with-firmware-path=/usr/lib/firmware/updates:/usr/lib/firmware
 \
 
 
  Am i missing something? I havn't yet found any solution yet, and journal
  isn't helping me much here.

 I think Michal just fixed this with this commit:


 http://cgit.freedesktop.org/systemd/systemd/commit/?id=6041a7ee2c1bbff6301082f192fc1b0882400d42

 Could you check, please?


 Lennart

 --
 Lennart Poettering, Red Hat

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [Question/bug] Timeout after bus_event_loop_with_idle() change.

2014-10-06 Thread Daniel Buch
On my system it is consistently.

okt 06 20:09:09 dbuch-laptop systemd[1]: systemd-timedated.service stopping
timed out. Terminating.
okt 06 20:09:09 dbuch-laptop systemd[1]: Unit systemd-timedated.service
entered failed state.
okt 06 20:09:09 dbuch-laptop systemd[1]: systemd-timedated.service failed.
okt 06 20:09:09 dbuch-laptop systemd[1]: systemd-hostnamed.service stopping
timed out. Terminating.
okt 06 20:09:09 dbuch-laptop systemd[1]: Unit systemd-hostnamed.service
entered failed state.
okt 06 20:09:09 dbuch-laptop systemd[1]: systemd-hostnamed.service failed.
okt 06 20:09:09 dbuch-laptop systemd[1]: systemd-localed.service stopping
timed out. Terminating.
okt 06 20:09:09 dbuch-laptop systemd[1]: Unit systemd-localed.service
entered failed state.
okt 06 20:09:09 dbuch-laptop systemd[1]: systemd-localed.service failed.

This happens every boot after the given timeout.

2014-10-04 18:26 GMT+02:00 David Herrmann dh.herrm...@gmail.com:

 Hi

 On Fri, Oct 3, 2014 at 10:00 PM, Daniel Buch boogiewasth...@gmail.com
 wrote:
  Hi,
 
  With current git and since 430e21c2f7e77d600257ead56419f51 i keep on
 getting
  timeout on these units
 

 I also occasionally get timeouts on bus-activated systemd services
 with -git. I haven't been able to reproduce it consistently. Maybe
 Lennart has an idea what's going wrong, otherwise I will spend some
 time pinning this down.

 Thanks
 David

  dbuch@dbuch-laptop ~/dev/systemd (git)-[master] % systemctl --failed
UNIT  LOAD   ACTIVE SUBDESCRIPTION
  ● systemd-hostnamed.service loaded failed failed Hostname Service
  ● systemd-localed.service   loaded failed failed Locale Service
  ● systemd-timedated.service loaded failed failed Time  Date Service
 
 
  My build config looks like this:
--libexecdir=/usr/lib \
--localstatedir=/var \
--sysconfdir=/etc \
--enable-introspection \
--enable-gtk-doc \
--enable-kdbus \
--enable-compat-libs \
--enable-timesyncd \
--enable-lz4 \
--enable-terminal \
--enable-resolved \
--disable-audit \
--disable-ima \
--disable-multi-seat-x \
--disable-smack \
--with-sysvinit-path= \
--with-sysvrcnd-path= \
--with-firmware-path=/usr/lib/firmware/updates:/usr/lib/firmware
 \
 
 
  Am i missing something? I havn't yet found any solution yet, and journal
  isn't helping me much here.
 
  Best regards, Daniel.
 
  ___
  systemd-devel mailing list
  systemd-devel@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/systemd-devel
 

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [Question/bug] Timeout after bus_event_loop_with_idle() change.

2014-10-04 Thread Daniel Buch
dbuch@dbuch-laptop ~ % systemctl status systemd-hostnamed.service -l
● systemd-hostnamed.service - Hostname Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-hostnamed.service;
static)
   Active: failed (Result: timeout) since lør 2014-10-04 08:14:52 CEST; 5h
7min ago
 Docs: man:systemd-hostnamed.service(8)
   man:hostname(5)
   man:machine-info(5)
   http://www.freedesktop.org/wiki/Software/systemd/hostnamed
  Process: 17795 ExecStart=/usr/lib/systemd/systemd-hostnamed (code=exited,
status=0/SUCCESS)
 Main PID: 17795 (code=exited, status=0/SUCCESS)

okt 04 08:12:52 dbuch-laptop systemd[1]: Started Hostname Service.
okt 04 08:14:52 dbuch-laptop systemd[1]: systemd-hostnamed.service stopping
timed out. Terminating.
okt 04 08:14:52 dbuch-laptop systemd[1]: Unit systemd-hostnamed.service
entered failed state.
okt 04 08:14:52 dbuch-laptop systemd[1]: systemd-hostnamed.service failed.


2014-10-04 7:12 GMT+02:00 Andrei Borzenkov arvidj...@gmail.com:

 В Fri, 3 Oct 2014 22:00:50 +0200
 Daniel Buch boogiewasth...@gmail.com пишет:

  Hi,
 
  With current git and since 430e21c2f7e77d600257ead56419f51 i keep on
  getting timeout on these units
 
  dbuch@dbuch-laptop ~/dev/systemd (git)-[master] % systemctl --failed
UNIT  LOAD   ACTIVE SUBDESCRIPTION
  ● systemd-hostnamed.service loaded failed failed Hostname Service
  ● systemd-localed.service   loaded failed failed Locale Service
  ● systemd-timedated.service loaded failed failed Time  Date Service
 

 Show systemctl status systemd-hostnamed.service
 systemd-localed.service systemd-timedated.service

 
  My build config looks like this:
--libexecdir=/usr/lib \
--localstatedir=/var \
--sysconfdir=/etc \
--enable-introspection \
--enable-gtk-doc \
--enable-kdbus \
--enable-compat-libs \
--enable-timesyncd \
--enable-lz4 \
--enable-terminal \
--enable-resolved \
--disable-audit \
--disable-ima \
--disable-multi-seat-x \
--disable-smack \
--with-sysvinit-path= \
--with-sysvrcnd-path= \
--with-firmware-path=/usr/lib/firmware/updates:/usr/lib/firmware
 \
 
 
  Am i missing something? I havn't yet found any solution yet, and journal
  isn't helping me much here.
 
  Best regards, Daniel.


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [Question/bug] Timeout after bus_event_loop_with_idle() change.

2014-10-03 Thread Daniel Buch
Hi,

With current git and since 430e21c2f7e77d600257ead56419f51 i keep on
getting timeout on these units

dbuch@dbuch-laptop ~/dev/systemd (git)-[master] % systemctl --failed
  UNIT  LOAD   ACTIVE SUBDESCRIPTION
● systemd-hostnamed.service loaded failed failed Hostname Service
● systemd-localed.service   loaded failed failed Locale Service
● systemd-timedated.service loaded failed failed Time  Date Service


My build config looks like this:
  --libexecdir=/usr/lib \
  --localstatedir=/var \
  --sysconfdir=/etc \
  --enable-introspection \
  --enable-gtk-doc \
  --enable-kdbus \
  --enable-compat-libs \
  --enable-timesyncd \
  --enable-lz4 \
  --enable-terminal \
  --enable-resolved \
  --disable-audit \
  --disable-ima \
  --disable-multi-seat-x \
  --disable-smack \
  --with-sysvinit-path= \
  --with-sysvrcnd-path= \
  --with-firmware-path=/usr/lib/firmware/updates:/usr/lib/firmware \


Am i missing something? I havn't yet found any solution yet, and journal
isn't helping me much here.

Best regards, Daniel.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] resolved: fix warnings

2014-08-14 Thread Daniel Buch
I just hit this assert on my arch system with gcc 4.9,

dbuch-laptop systemd-resolved[457]: Assertion 's-protocol ==
DNS_PROTOCOL_LLMNR' failed at src/resolve/resolved-dns-scope.c:369


2014-08-14 19:58 GMT+02:00 Lennart Poettering lenn...@poettering.net:

 On Sat, 19.07.14 10:37, Thomas H.P. Andersen (pho...@gmail.com) wrote:

  --- a/src/resolve/resolved-dns-scope.c
  +++ b/src/resolve/resolved-dns-scope.c
  @@ -292,7 +292,7 @@ int dns_scope_llmnr_membership(DnsScope *s, bool b) {
   if (s-family == AF_INET) {
   struct ip_mreqn mreqn = {
   .imr_multiaddr = LLMNR_MULTICAST_IPV4_ADDRESS,
  -.imr_ifindex = s-link-ifindex,
  +.imr_ifindex = s-link ? s-link-ifindex : 0,

 LLMNR scopes don't exist with a NULL link value, they are strictly bound
 to physical links.

 I have now added a couple of assert()s to the function, that should
 clarify that and hopefully tell the compiler that these are necessarily
 initialized.

 Does this make things work for you? Please check.

 Lennart

 --
 Lennart Poettering, Red Hat
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd-timesync fails

2014-08-13 Thread Daniel Buch
With current git i noticed systemd-timesyncd failed and complain like this,
log attached below.

aug 13 20:12:08 dbuch-laptop systemd[1]: Starting Network Time
Synchronization...
aug 13 20:12:08 dbuch-laptop systemd[1]: systemd-timesyncd.service: main
process exited, code=exited, status=1/FAILURE
aug 13 20:12:08 dbuch-laptop systemd[1]: Failed to start Network Time
Synchronization.
aug 13 20:12:08 dbuch-laptop systemd[1]: Unit systemd-timesyncd.service
entered failed state.
aug 13 20:12:08 dbuch-laptop systemd[1]: systemd-timesyncd.service has no
holdoff time, scheduling restart.
aug 13 20:12:08 dbuch-laptop systemd-timesyncd[377]: Failed to allocate
manager: No data available
aug 13 20:12:08 dbuch-laptop systemd[1]: systemd-timesyncd.service: main
process exited, code=exited, status=1/FAILURE
aug 13 20:12:08 dbuch-laptop systemd[1]: Failed to start Network Time
Synchronization.
aug 13 20:12:08 dbuch-laptop systemd[1]: Unit systemd-timesyncd.service
entered failed state.
aug 13 20:12:08 dbuch-laptop systemd[1]: systemd-timesyncd.service has no
holdoff time, scheduling restart.
aug 13 20:12:08 dbuch-laptop systemd[1]: Stopping Network Time
Synchronization...
aug 13 20:12:08 dbuch-laptop systemd[1]: Starting Network Time
Synchronization...
aug 13 20:12:08 dbuch-laptop systemd-timesyncd[385]: Failed to allocate
manager: No data available

Is this known or am i missing some configuration where i need opt-in?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd-timesync fails

2014-08-13 Thread Daniel Buch
Indeed, i run gnome and gnomes NetworkManager.

I just tested the binary approach with LOG_LEVEL=debug (log attached below
and it worked, also systemctl start systemd-timesyncd.service works.

Added new server time1.google.com.
Added new server time2.google.com.
Added new server time3.google.com.
Added new server time4.google.com.
systemd-timesyncd running as pid 985
Selected server time1.google.com.
Resolving time1.google.com...
Resolved address 216.239.32.15:123 for time1.google.com.
Resolved address [2001:4860:4802:32::f]:123 for time1.google.com.
Selected address 216.239.32.15:123 of server time1.google.com.
Using NTP server 216.239.32.15:123 (time1.google.com).
Sent NTP request to 216.239.32.15:123 (time1.google.com).
NTP response:
  leap : 0
  version  : 4
  mode : 4
  stratum  : 2
  precision: 0.01 sec (-20)
  reference: n/a
  origin   : 1407956263.690
  receive  : 1407956263.355
  transmit : 1407956263.355
  dest : 1407956263.731
  offset   : -0.355 sec
  delay: +0.040 sec
  packet count : 1
  jitter   : 0.000
  poll interval: 32
  adjust (slew): -0.355 sec
  status   : 8193 sync
  time now : 1407956263.730
  constant : 1
  offset   : -0.355 sec
  freq offset  : +0 (0 ppm)
interval/delta/delay/jitter/drift 32s/-0.355s/0.040s/0.000s/+0ppm



2014-08-13 20:47 GMT+02:00 Lennart Poettering lenn...@poettering.net:

 On Wed, 13.08.14 20:35, Daniel Buch (boogiewasth...@gmail.com) wrote:

  With current git i noticed systemd-timesyncd failed and complain like
 this,
  log attached below.
 
  aug 13 20:12:08 dbuch-laptop systemd[1]: Starting Network Time
  Synchronization...
  aug 13 20:12:08 dbuch-laptop systemd[1]: systemd-timesyncd.service: main
  process exited, code=exited, status=1/FAILURE
  aug 13 20:12:08 dbuch-laptop systemd[1]: Failed to start Network Time
  Synchronization.
  aug 13 20:12:08 dbuch-laptop systemd[1]: Unit systemd-timesyncd.service
  entered failed state.
  aug 13 20:12:08 dbuch-laptop systemd[1]: systemd-timesyncd.service has no
  holdoff time, scheduling restart.
  aug 13 20:12:08 dbuch-laptop systemd-timesyncd[377]: Failed to allocate
  manager: No data available
  aug 13 20:12:08 dbuch-laptop systemd[1]: systemd-timesyncd.service: main
  process exited, code=exited, status=1/FAILURE
  aug 13 20:12:08 dbuch-laptop systemd[1]: Failed to start Network Time
  Synchronization.
  aug 13 20:12:08 dbuch-laptop systemd[1]: Unit systemd-timesyncd.service
  entered failed state.
  aug 13 20:12:08 dbuch-laptop systemd[1]: systemd-timesyncd.service has no
  holdoff time, scheduling restart.
  aug 13 20:12:08 dbuch-laptop systemd[1]: Stopping Network Time
  Synchronization...
  aug 13 20:12:08 dbuch-laptop systemd[1]: Starting Network Time
  Synchronization...
  aug 13 20:12:08 dbuch-laptop systemd-timesyncd[385]: Failed to allocate
  manager: No data available
 
  Is this known or am i missing some configuration where i need opt-in?

 Hmm, ENODATA? That smells like something returned by sd-network, but I
 can't see how that could happen... I figure you run things without
 networkd? (which is totally ok and supported, just asking...)

 If you run the binary from the command line, does it fail too? If so,
 can you run it in gdb, and maybe step through it, to see where it fails?

 Also, setting SYSTEMD_LOG_LEVEL=debug as env var for it might be
 interesting too...

 Lennart

 --
 Lennart Poettering, Red Hat

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd-timesync fails

2014-08-13 Thread Daniel Buch
Cool, its fixed.


2014-08-13 21:08 GMT+02:00 Lennart Poettering lenn...@poettering.net:

 On Wed, 13.08.14 21:01, Daniel Buch (boogiewasth...@gmail.com) wrote:

  Indeed, i run gnome and gnomes NetworkManager.
 
  I just tested the binary approach with LOG_LEVEL=debug (log attached
 below
  and it worked, also systemctl start systemd-timesyncd.service works.

 I think I fixed it now in git. Can you check please?

 Lennart

 --
 Lennart Poettering, Red Hat

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] networkctl: color status dump without link name

2014-08-13 Thread Daniel Buch
Lets mimic colored operational state dump as if link name is appiled
---
 src/network/networkctl.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 731ad27..9c4c1b7 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -427,11 +427,19 @@ static int link_status(char **args, unsigned n) {
 _cleanup_free_ char *operational_state = NULL;
 _cleanup_strv_free_ char **dns = NULL, **ntp = NULL;
 _cleanup_free_ struct local_address *addresses = NULL;
+const char *on_color_oper = , *off_color_oper = ;
 int i, c;
 
 sd_network_get_operational_state(operational_state);
-if (operational_state)
-printf(   State: %s\n, operational_state);
+if (streq_ptr(operational_state, routable)) {
+on_color_oper = ansi_highlight_green();
+off_color_oper = ansi_highlight_off();
+} else if (streq_ptr(operational_state, degraded)) {
+on_color_oper = ansi_highlight_yellow();
+off_color_oper = ansi_highlight_off();
+}
+
+printf(   State: %s%s%s\n, on_color_oper, 
strna(operational_state), off_color_oper);
 
 c = local_addresses(rtnl, 0, addresses);
 for (i = 0; i  c; i++) {
-- 
2.0.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] analyze: fix seg-fault with no cl-argument

2014-07-24 Thread Daniel Buch
We need to check if argv[1] is set before compare
---
 src/analyze/analyze.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 66e2aab..83da7f5 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -1349,7 +1349,7 @@ int main(int argc, char *argv[]) {
 if (r = 0)
 goto finish;
 
-if (streq(argv[optind], verify))
+if (argv[optind]  streq(argv[optind], verify))
 r = verify_units(argv+optind+1,
  arg_user ? SYSTEMD_USER : SYSTEMD_SYSTEM,
  arg_man);
-- 
2.0.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] coredump: suppress uninitialized sz warning

2014-07-23 Thread Daniel Buch
Its false positive but lets make gcc happy
---
 src/journal/coredump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 182c2b1..a361a51 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -700,7 +700,7 @@ log:
 /* Optionally store the entire coredump in the journal */
 if (IN_SET(arg_storage, COREDUMP_STORAGE_JOURNAL, 
COREDUMP_STORAGE_BOTH) 
 coredump_size = (off_t) arg_journal_size_max) {
-size_t sz;
+size_t sz = 0;
 
 /* Store the coredump itself in the journal */
 
-- 
2.0.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] systemd-verify: call help() and exit if no CL-argument

2014-07-21 Thread Daniel Buch
Im not sure if we want the help approach or just fail?

I can change this and resed if you want.

Assertion 'strv_uniq(ans)' failed at src/verify/verify.c:53, function 
generate_path(). Aborting.
[1]4795 abort (core dumped)  systemd-verify
---
 src/verify/verify.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/verify/verify.c b/src/verify/verify.c
index c1a3da8..b9f4372 100644
--- a/src/verify/verify.c
+++ b/src/verify/verify.c
@@ -300,13 +300,20 @@ static int parse_argv(int argc, char *argv[]) {
 {}
 };
 
-int c;
+int c, left;
 
 assert(argc = 1);
 assert(argv);
 
 opterr = 0;
 
+left = argc - optind;
+
+if (left = 0) {
+help();
+return -EINVAL;
+}
+
 while ((c = getopt_long(argc, argv, :h, options, NULL)) = 0)
 switch (c) {
 
-- 
2.0.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] ask-password-api.c: fix assigned but not read warning

2014-06-26 Thread Daniel Buch
Not sure this is an appropiate fix, feel free to leave it out

---
 src/shared/ask-password-api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index 5997a03..39eab0d 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -344,7 +344,7 @@ int ask_password_agent(
 
 fd = -1;
 
-signal_fd = signalfd(-1, mask, SFD_NONBLOCK|SFD_CLOEXEC);
+signal_fd = signalfd(fd, mask, SFD_NONBLOCK|SFD_CLOEXEC);
 if (signal_fd  0) {
 log_error(signalfd(): %m);
 r = -errno;
-- 
2.0.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] ask-password-api.c: fix assigned but not read warning

2014-06-26 Thread Daniel Buch
Well we assign fd to be -1 above signalfd() and afterwards never read it.
That's what my compiler complained about.

Thinking further i guess its the assignment thats redundant since cleanup
attribute calls safe_close() that basiclly assigns fd to be -1.


I got, gcc version 4.9.0 20140604 (prerelease) (GCC)


2014-06-26 13:12 GMT+02:00 Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl:

 On Thu, Jun 26, 2014 at 12:50:40PM +0200, Daniel Buch wrote:
  Not sure this is an appropiate fix, feel free to leave it out
 
  ---
   src/shared/ask-password-api.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
 
  diff --git a/src/shared/ask-password-api.c
 b/src/shared/ask-password-api.c
  index 5997a03..39eab0d 100644
  --- a/src/shared/ask-password-api.c
  +++ b/src/shared/ask-password-api.c
  @@ -344,7 +344,7 @@ int ask_password_agent(
 
   fd = -1;
 
  -signal_fd = signalfd(-1, mask, SFD_NONBLOCK|SFD_CLOEXEC);
  +signal_fd = signalfd(fd, mask, SFD_NONBLOCK|SFD_CLOEXEC);
   if (signal_fd  0) {
   log_error(signalfd(): %m);
   r = -errno;
 The compiler should not warn here, since fd has a cleanup function defined,
 which obviously looks at fd. What compiler and version is that?

 Zbyszek


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] ask-password-api.c: fix assigned but not read warning

2014-06-26 Thread Daniel Buch
You are right! Sorry for the confusion


2014-06-26 14:04 GMT+02:00 Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl:

 On Thu, Jun 26, 2014 at 01:49:56PM +0200, Daniel Buch wrote:
  Well we assign fd to be -1 above signalfd() and afterwards never read it.
  That's what my compiler complained about.
 
  Thinking further i guess its the assignment thats redundant since cleanup
  attribute calls safe_close() that basiclly assigns fd to be -1.
 No, it's not redundant. If it wasn't assigned to -1, it would be closed on
 the
 exit from function, resultin in a double close, the first time when f is
 destroyed.

  I got, gcc version 4.9.0 20140604 (prerelease) (GCC)
 You might want to report this as a regression then, I don't think we had
 this warning before.

 Zbyszek

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] bus-policy.c: use draw_special_char(DRAW_ARROW)

2014-06-08 Thread Daniel Buch
Lets allow LC_ALL=C without corrupted output
---
 src/bus-proxyd/bus-policy.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/bus-proxyd/bus-policy.c b/src/bus-proxyd/bus-policy.c
index 053495c..2df4bf7 100644
--- a/src/bus-proxyd/bus-policy.c
+++ b/src/bus-proxyd/bus-policy.c
@@ -644,16 +644,16 @@ static void dump_hashmap_items(Hashmap *h) {
 
 noreturn void policy_dump(Policy *p) {
 
-printf(→ Default Items:\n);
+printf(%s Default Items:\n, draw_special_char(DRAW_ARROW));
 dump_items(p-default_items);
 
-printf(→ Mandatory Items:\n);
+printf(%s Mandatory Items:\n, draw_special_char(DRAW_ARROW));
 dump_items(p-mandatory_items);
 
-printf(→ Group Items:\n);
+printf(%s Group Items:\n, draw_special_char(DRAW_ARROW));
 dump_hashmap_items(p-group_items);
 
-printf(→ User Items:\n);
+printf(%s User Items:\n, draw_special_char(DRAW_ARROW));
 dump_hashmap_items(p-user_items);
 exit(0);
 }
-- 
2.0.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] error: undefined reference to `sd_event_source_unref' while the function exists in source

2014-05-14 Thread Daniel Buch
Have you compiled with: -lsystemd?


2014-05-14 11:48 GMT+02:00 Hurry Zeng winew...@qq.com:

 Hi All,

 i tried to compile some source code on archlinux (v 2014.05.01), but i got
 an error: (header missing ?)
 fatal error:* systemd/sd-event.h*: No such file or directory
 #include systemd/sd-event.h
 ^
 compilation terminated.

 then i copied the headers from systemd-212.tar.gz
 to /usr/include/systemd/  and make again,
 but i got more errors, such as: (implementation missing ?)
 undefined reference to `*sd_event_source_unref*'

 i found the undefined  functions in systemd source code,
 but why the make program can't find them?
 what mistake i had made ?

 Is somebody online ? plz help !

 thanks
 Hurry

 --
 Hurry Zeng from China. (winew...@qq.com)

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [KDBUS PATCH] remove unused variable

2014-04-09 Thread Daniel Buch
---
 connection.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/connection.c b/connection.c
index 2d69f17..5e7d553 100644
--- a/connection.c
+++ b/connection.c
@@ -1024,7 +1024,7 @@ int kdbus_cmd_msg_recv(struct kdbus_conn *conn,
 
/* just drop the message */
if (recv-flags  KDBUS_RECV_DROP) {
-   struct kdbus_conn_reply *r, *reply = NULL;
+   struct kdbus_conn_reply *reply = NULL;
bool reply_found = false;
 
if (queue-reply) {
-- 
1.9.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [KDBUS PATCH] remove unused variable

2014-04-09 Thread Daniel Buch
No problem :)


2014-04-09 11:46 GMT+02:00 Daniel Mack dan...@zonque.org:

 On 04/09/2014 11:43 AM, Daniel Buch wrote:
  ---
   connection.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
 
  diff --git a/connection.c b/connection.c
  index 2d69f17..5e7d553 100644
  --- a/connection.c
  +++ b/connection.c
  @@ -1024,7 +1024,7 @@ int kdbus_cmd_msg_recv(struct kdbus_conn *conn,
 
/* just drop the message */
if (recv-flags  KDBUS_RECV_DROP) {
  - struct kdbus_conn_reply *r, *reply = NULL;
  + struct kdbus_conn_reply *reply = NULL;
bool reply_found = false;
 
if (queue-reply) {
 

 Oops, I just realized that I forgot to push my own version of that patch
 which I had locally since some days. Did that right now.

 Sorry, but thanks for your submission!


 Daniel


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] build-sys: workaround scan-build bug to fix ./autogen.sh s

2014-04-01 Thread Daniel Buch
It seems to be a clang-analyzer problem since it don't behave like
clang-compiler regarding -std={c99,gnu99}
---
 autogen.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/autogen.sh b/autogen.sh
index 9b4781c..449a2e6 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -72,7 +72,7 @@ elif [ x$1 = xl ]; then
 $topdir/configure CC=clang CFLAGS='-g -O0 -ftrapv -Wno-gnu' 
--enable-compat-libs --enable-kdbus $args
 make clean
 elif [ x$1 = xs ]; then
-scan-build $topdir/configure CFLAGS='-g -O0 -ftrapv' 
--enable-compat-libs --enable-kdbus $args
+scan-build $topdir/configure CFLAGS='-std=gnu99 -g -O0 -ftrapv' 
--enable-compat-libs --enable-kdbus $args
 scan-build make
 else
 echo
-- 
1.9.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] test-resolve.c: Cleanup and make use of sockaddr_pretty()

2014-03-26 Thread Daniel Buch
---
 src/libsystemd/sd-resolve/test-resolve.c | 48 +++-
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/src/libsystemd/sd-resolve/test-resolve.c 
b/src/libsystemd/sd-resolve/test-resolve.c
index d3b2d55..6334dad 100644
--- a/src/libsystemd/sd-resolve/test-resolve.c
+++ b/src/libsystemd/sd-resolve/test-resolve.c
@@ -4,6 +4,7 @@
   This file is part of systemd.
 
   Copyright 2005-2008 Lennart Poettering
+  Copyright 2014 Daniel Buch
 
   systemd is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by
@@ -31,36 +32,39 @@
 #include signal.h
 #include errno.h
 
+#include socket-util.h
 #include sd-resolve.h
 #include resolve-util.h
 #include macro.h
 
 int main(int argc, char *argv[]) {
-int r = 1;
+int r = 0;
 _cleanup_resolve_unref_ sd_resolve *resolve = NULL;
 _cleanup_resolve_addrinfo_free_ struct addrinfo *ai = NULL;
 _cleanup_free_ unsigned char *srv = NULL;
-sd_resolve_query *q1 = NULL, *q2 = NULL, *q3 = NULL;
-struct addrinfo hints = {};
-struct sockaddr_in sa = {};
 _cleanup_free_ char *host = NULL, *serv = NULL;
+sd_resolve_query *q1 = NULL, *q2 = NULL, *q3 = NULL;
+
+struct addrinfo hints = {
+.ai_family = PF_UNSPEC,
+.ai_socktype = SOCK_STREAM,
+.ai_flags = AI_CANONNAME
+};
+
+struct sockaddr_in sa = {
+.sin_family = AF_INET,
+.sin_port = htons(80)
+};
 
 assert_se(sd_resolve_new(resolve) = 0);
 
 /* Make a name - address query */
-hints.ai_family = PF_UNSPEC;
-hints.ai_socktype = SOCK_STREAM;
-hints.ai_flags = AI_CANONNAME;
-
 r = sd_resolve_getaddrinfo(resolve, q1, argc = 2 ? argv[1] : 
www.heise.de, NULL, hints);
 if (r  0)
 log_error(sd_resolve_getaddrinfo(): %s\n, strerror(-r));
 
 /* Make an address - name query */
-sa.sin_family = AF_INET;
-sa.sin_addr.s_addr = inet_addr(argc = 3 ? argv[2] : 193.99.144.71);
-sa.sin_port = htons(80);
-
+sa.sin_addr.s_addr = inet_addr(argc = 3 ? argv[2] : 193.99.144.71),
 r = sd_resolve_getnameinfo(resolve, q2, (struct sockaddr*) sa, 
sizeof(sa), 0, true, true);
 if (r  0)
 log_error(sd_resolve_getnameinfo(): %s\n, strerror(-r));
@@ -90,15 +94,11 @@ int main(int argc, char *argv[]) {
 struct addrinfo *i;
 
 for (i = ai; i; i = i-ai_next) {
-char t[256];
-const char *p = NULL;
+_cleanup_free_ char *addr = NULL;
 
-if (i-ai_family == PF_INET)
-p = inet_ntop(AF_INET, ((struct sockaddr_in*) 
i-ai_addr)-sin_addr, t, sizeof(t));
-else if (i-ai_family == PF_INET6)
-p = inet_ntop(AF_INET6, ((struct 
sockaddr_in6*) i-ai_addr)-sin6_addr, t, sizeof(t));
+assert_se(sockaddr_pretty(i-ai_addr, i-ai_addrlen, 
false, addr) == 0);
 
-printf(%s\n, p);
+puts(addr);
 }
 
 printf(canonical name: %s\n, strna(ai-ai_canonname));
@@ -109,7 +109,7 @@ int main(int argc, char *argv[]) {
 if (r)
 log_error(error: %s %i\n, gai_strerror(r), r);
 else
-printf(%s -- %s\n, host, serv);
+printf(Host: %s -- Serv: %s\n, host, serv);
 
 /* Interpret the result of the SRV lookup */
 r = sd_resolve_res_done(q3, srv);
@@ -118,9 +118,7 @@ int main(int argc, char *argv[]) {
 else if (r == 0)
 log_error(No reply for SRV lookup\n);
 else {
-int qdcount;
-int ancount;
-int len;
+int qdcount, ancount, len;
 const unsigned char *pos = srv + sizeof(HEADER);
 unsigned char *end = srv + r;
 HEADER *head = (HEADER *)srv;
@@ -157,7 +155,5 @@ int main(int argc, char *argv[]) {
 }
 }
 
-r = 0;
-
-return r;
+return 0;
 }
-- 
1.9.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] test-resolve.c: cleanup alittle bit and make use of sockaddr_pretty()

2014-03-15 Thread Daniel Buch
---
 src/libsystemd/sd-resolve/test-resolve.c | 48 +++-
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/src/libsystemd/sd-resolve/test-resolve.c 
b/src/libsystemd/sd-resolve/test-resolve.c
index d3b2d55..c9bcbfc 100644
--- a/src/libsystemd/sd-resolve/test-resolve.c
+++ b/src/libsystemd/sd-resolve/test-resolve.c
@@ -4,6 +4,7 @@
   This file is part of systemd.
 
   Copyright 2005-2008 Lennart Poettering
+  Copyright 2014 Daniel Buch
 
   systemd is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by
@@ -31,36 +32,39 @@
 #include signal.h
 #include errno.h
 
+#include socket-util.h
 #include sd-resolve.h
 #include resolve-util.h
 #include macro.h
 
 int main(int argc, char *argv[]) {
-int r = 1;
+int r = 0;
 _cleanup_resolve_unref_ sd_resolve *resolve = NULL;
 _cleanup_resolve_addrinfo_free_ struct addrinfo *ai = NULL;
 _cleanup_free_ unsigned char *srv = NULL;
-sd_resolve_query *q1 = NULL, *q2 = NULL, *q3 = NULL;
-struct addrinfo hints = {};
-struct sockaddr_in sa = {};
 _cleanup_free_ char *host = NULL, *serv = NULL;
+sd_resolve_query *q1 = NULL, *q2 = NULL, *q3 = NULL;
+
+struct addrinfo hints = {
+.ai_family = PF_UNSPEC,
+.ai_socktype = SOCK_STREAM,
+.ai_flags = AI_CANONNAME
+};
+
+struct sockaddr_in sa = {
+.sin_family = AF_INET,
+.sin_addr.s_addr = inet_addr(argc = 3 ? argv[2] : 
193.99.144.71),
+.sin_port = htons(80)
+};
 
 assert_se(sd_resolve_new(resolve) = 0);
 
 /* Make a name - address query */
-hints.ai_family = PF_UNSPEC;
-hints.ai_socktype = SOCK_STREAM;
-hints.ai_flags = AI_CANONNAME;
-
 r = sd_resolve_getaddrinfo(resolve, q1, argc = 2 ? argv[1] : 
www.heise.de, NULL, hints);
 if (r  0)
 log_error(sd_resolve_getaddrinfo(): %s\n, strerror(-r));
 
 /* Make an address - name query */
-sa.sin_family = AF_INET;
-sa.sin_addr.s_addr = inet_addr(argc = 3 ? argv[2] : 193.99.144.71);
-sa.sin_port = htons(80);
-
 r = sd_resolve_getnameinfo(resolve, q2, (struct sockaddr*) sa, 
sizeof(sa), 0, true, true);
 if (r  0)
 log_error(sd_resolve_getnameinfo(): %s\n, strerror(-r));
@@ -90,15 +94,11 @@ int main(int argc, char *argv[]) {
 struct addrinfo *i;
 
 for (i = ai; i; i = i-ai_next) {
-char t[256];
-const char *p = NULL;
+_cleanup_free_ char *addr = NULL;
 
-if (i-ai_family == PF_INET)
-p = inet_ntop(AF_INET, ((struct sockaddr_in*) 
i-ai_addr)-sin_addr, t, sizeof(t));
-else if (i-ai_family == PF_INET6)
-p = inet_ntop(AF_INET6, ((struct 
sockaddr_in6*) i-ai_addr)-sin6_addr, t, sizeof(t));
+assert_se(sockaddr_pretty(i-ai_addr, i-ai_addrlen, 
false, addr) == 0);
 
-printf(%s\n, p);
+puts(addr);
 }
 
 printf(canonical name: %s\n, strna(ai-ai_canonname));
@@ -109,7 +109,7 @@ int main(int argc, char *argv[]) {
 if (r)
 log_error(error: %s %i\n, gai_strerror(r), r);
 else
-printf(%s -- %s\n, host, serv);
+printf(Host: %s -- Serv: %s\n, host, serv);
 
 /* Interpret the result of the SRV lookup */
 r = sd_resolve_res_done(q3, srv);
@@ -118,9 +118,7 @@ int main(int argc, char *argv[]) {
 else if (r == 0)
 log_error(No reply for SRV lookup\n);
 else {
-int qdcount;
-int ancount;
-int len;
+int qdcount, ancount, len;
 const unsigned char *pos = srv + sizeof(HEADER);
 unsigned char *end = srv + r;
 HEADER *head = (HEADER *)srv;
@@ -157,7 +155,5 @@ int main(int argc, char *argv[]) {
 }
 }
 
-r = 0;
-
-return r;
+return 0;
 }
-- 
1.9.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] socket.c: make use of union sockaddr_union

2014-03-12 Thread Daniel Buch
---
 src/core/socket.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/core/socket.c b/src/core/socket.c
index 35531ed..8ecc9f9 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -597,13 +597,7 @@ static void socket_dump(Unit *u, FILE *f, const char 
*prefix) {
 static int instance_from_socket(int fd, unsigned nr, char **instance) {
 socklen_t l;
 char *r;
-union {
-struct sockaddr sa;
-struct sockaddr_un un;
-struct sockaddr_in in;
-struct sockaddr_in6 in6;
-struct sockaddr_storage storage;
-} local, remote;
+union sockaddr_union local, remote;
 
 assert(fd = 0);
 assert(instance);
-- 
1.9.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] tests: add set -e

2014-02-28 Thread Daniel Buch
---
 TODO| 1 -
 test/TEST-01-BASIC/test.sh  | 2 ++
 test/TEST-02-CRYPTSETUP/test.sh | 2 ++
 test/TEST-03-JOBS/test-jobs.sh  | 1 +
 test/TEST-03-JOBS/test.sh   | 2 ++
 test/rules-test.sh  | 2 ++
 6 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/TODO b/TODO
index 6cac3e2..a790683 100644
--- a/TODO
+++ b/TODO
@@ -215,7 +215,6 @@ Features:
 * cgtop: make cgtop useful in a container
 
 * test/:
-  - add 'set -e' to scripts in test/
   - make stuff in test/ work with separate output dir
 
 * systemctl delete x.snapshot leaves no trace in logs (at least at default 
level).
diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh
index 84ccf26..19b6ee7 100755
--- a/test/TEST-01-BASIC/test.sh
+++ b/test/TEST-01-BASIC/test.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
+set -e
+
 TEST_DESCRIPTION=Basic systemd setup
 
 . $TEST_BASE_DIR/test-functions
diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh
index b243254..aaa48fe 100755
--- a/test/TEST-02-CRYPTSETUP/test.sh
+++ b/test/TEST-02-CRYPTSETUP/test.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
+set -e
+
 TEST_DESCRIPTION=cryptsetup systemd setup
 
 . $TEST_BASE_DIR/test-functions
diff --git a/test/TEST-03-JOBS/test-jobs.sh b/test/TEST-03-JOBS/test-jobs.sh
index 12b38af..dabee54 100755
--- a/test/TEST-03-JOBS/test-jobs.sh
+++ b/test/TEST-03-JOBS/test-jobs.sh
@@ -1,4 +1,5 @@
 #!/bin/bash -x
+set -e
 
 # Test merging of a --ignore-dependencies job into a previously
 # installed job.
diff --git a/test/TEST-03-JOBS/test.sh b/test/TEST-03-JOBS/test.sh
index 41e02e2..0bcef5f 100755
--- a/test/TEST-03-JOBS/test.sh
+++ b/test/TEST-03-JOBS/test.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
+set -e
+
 TEST_DESCRIPTION=Job-related tests
 
 . $TEST_BASE_DIR/test-functions
diff --git a/test/rules-test.sh b/test/rules-test.sh
index 47d42cb..25cfc98 100755
--- a/test/rules-test.sh
+++ b/test/rules-test.sh
@@ -17,6 +17,8 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with systemd; If not, see http://www.gnu.org/licenses/.
 
+set -e
+
 [ -n $srcdir ] || srcdir=`dirname $0`/..
 
 # skip if we don't have python
-- 
1.9.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [RFC] socket-proxyd: resolve addrinfo using sd-resolve

2014-02-20 Thread Daniel Buch
Hi,

Hope this is not completly ridiculous?
I havnt tested this since im not entirely sure how to do it.
So tips and comments regarding that are very welcome, im tempt to research 
further and maybe eventually provide a test for socket-proxy.

Best regards.

---
 Makefile.am  |  4 +++-
 TODO |  2 --
 src/socket-proxy/socket-proxyd.c | 29 +++--
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 03a65bf..a50a032 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -195,6 +195,7 @@ AM_CPPFLAGS = \
-I $(top_builddir)/src/udev \
-I $(top_srcdir)/src/libsystemd/sd-bus \
-I $(top_srcdir)/src/libsystemd/sd-event \
+   -I $(top_srcdir)/src/libsystemd/sd-resolve \
-I $(top_srcdir)/src/libsystemd/sd-rtnl \
$(OUR_CPPFLAGS)
 
@@ -3315,7 +3316,8 @@ systemd_socket_proxyd_LDADD = \
libsystemd-logs.la \
libsystemd-internal.la \
libsystemd-journal-internal.la \
-   libsystemd-shared.la
+   libsystemd-shared.la \
+   -lresolv
 
 # 
--
 if ENABLE_COREDUMP
diff --git a/TODO b/TODO
index 0ae1427..c6ccc8c 100644
--- a/TODO
+++ b/TODO
@@ -113,8 +113,6 @@ Features:
 
 * Automatically configure swap partition to use for hibernation by looking for 
largest swap partition on the root disk?
 
-* socket-proxyd: Use sd-resolve to resolve the server address
-
 * rfkill,backlight: we probably should run the load tools inside of the udev 
rules so that the state is properly initialized by the time other software sees 
it
 
 * move config_parse_path_strv() out of conf-parser.c
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index a42e5ae..cd9b95b 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -40,13 +40,12 @@
 #include build.h
 #include set.h
 #include path-util.h
+#include sd-resolve.h
+#include resolve-util.h
 
 #define BUFFER_SIZE (256 * 1024)
 #define CONNECTIONS_MAX 256
 
-#define _cleanup_freeaddrinfo_ _cleanup_(freeaddrinfop)
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo *, freeaddrinfo);
-
 typedef struct Context {
 Set *listen;
 Set *connections;
@@ -125,7 +124,9 @@ static int get_remote_sockaddr(union sockaddr_union *sa, 
socklen_t *salen) {
 *salen = offsetof(union sockaddr_union, un.sun_path) + 1 + 
strlen(sa-un.sun_path + 1);
 
 } else {
-_cleanup_freeaddrinfo_ struct addrinfo *result = NULL;
+_cleanup_resolve_unref_ sd_resolve *resolve = NULL;
+_cleanup_resolve_addrinfo_free_ struct addrinfo *result = NULL;
+sd_resolve_query *q = NULL;
 const char *node, *service;
 
 struct addrinfo hints = {
@@ -134,6 +135,10 @@ static int get_remote_sockaddr(union sockaddr_union *sa, 
socklen_t *salen) {
 .ai_flags = AI_ADDRCONFIG
 };
 
+r = sd_resolve_new(resolve);
+if (r  0)
+return -ENOMEM;
+
 service = strrchr(arg_remote_host, ':');
 if (service) {
 node = strndupa(arg_remote_host, service - 
arg_remote_host);
@@ -144,8 +149,20 @@ static int get_remote_sockaddr(union sockaddr_union *sa, 
socklen_t *salen) {
 }
 
 log_debug(Looking up address info for %s:%s, node, service);
-r = getaddrinfo(node, service, hints, result);
-if (r != 0) {
+r = sd_resolve_getaddrinfo(resolve, q, node, service, hints);
+if (r  0)
+log_error(Error: %s %d\n, gai_strerror(r), r);
+
+while (!sd_resolve_is_done(q)) {
+r = sd_resolve_wait(resolve, (uint64_t) -1);
+if (r  0) {
+log_error(Error: %s\n, strerror(-r));
+assert_not_reached(sd_resolve_wait() failed);
+}
+}
+
+r = sd_resolve_getaddrinfo_done(q, result);
+if (r  0) {
 log_error(Failed to resolve host %s:%s: %s, node, 
service, gai_strerror(r));
 return -EHOSTUNREACH;
 }
-- 
1.9.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] NEWS: sd-resolv.h is sd-resolve.h

2014-02-17 Thread Daniel Buch
---
 NEWS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 6a6635b..5da5891 100644
--- a/NEWS
+++ b/NEWS
@@ -212,7 +212,7 @@ CHANGES WITH 209:
   time, and those which should be run only at boot (for
   example, a line that creates /run/nologin).
 
-* A new API sd-resolv.h has been added which provides a simple
+* A new API sd-resolve.h has been added which provides a simple
   asynchronous wrapper around glibc NSS host name resolution
   calls, such as getaddrinfo(). In contrast to glibc's
   getaddrinfo_a(), it does not use signals. In contrast to most
-- 
1.9.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/3] sd-resolve: Allocate objects with new()

2014-01-18 Thread Daniel Buch
---
 src/libsystemd/sd-resolve.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index 6958aa9..7cc8dc4 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -423,7 +423,7 @@ sd_resolve* sd_resolve_new(unsigned n_proc) {
 if (n_proc  MAX_WORKERS)
 n_proc = MAX_WORKERS;
 
-resolve = malloc(sizeof(sd_resolve));
+resolve = new(sd_resolve, 1);
 if (!resolve) {
 errno = ENOMEM;
 goto fail;
@@ -562,7 +562,7 @@ static const void *unserialize_addrinfo(const void *p, 
struct addrinfo **ret_ai,
 if (*length  l)
 return NULL;
 
-ai = malloc(sizeof(struct addrinfo));
+ai = new(struct addrinfo, 1);
 if (!ai)
 goto fail;
 
@@ -765,7 +765,7 @@ static sd_resolve_query *alloc_query(sd_resolve *resolve) {
 resolve-current_index -= MAX_QUERIES;
 }
 
-q = resolve-queries[resolve-current_index] = 
malloc(sizeof(sd_resolve_query));
+q = resolve-queries[resolve-current_index] = new(sd_resolve_query, 
1);
 if (!q) {
 errno = ENOMEM;
 return NULL;
-- 
1.8.5.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/3] sd-resolve: get rid of sd_resolve_freeanswer()

2014-01-18 Thread Daniel Buch
---
 TODO  |  1 -
 src/libsystemd/resolve-util.h |  2 --
 src/libsystemd/sd-resolve.c   | 11 ---
 src/libsystemd/test-resolve.c |  2 +-
 4 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/TODO b/TODO
index a567669..91a7bda 100644
--- a/TODO
+++ b/TODO
@@ -35,7 +35,6 @@ Features:
 * sd-resolve:
   - make sure event loop integration works similar to event loop integration 
in other libs
   - maybe drop _free() call, introduce _unref() instead
-  - sd_resolve_freeanswer() is probably pointless, we don't define such a 
function for any other return values, but expect people to call free directly
   - maybe simplify function calls that take a sd_resolve_query object, to not 
also require the matching sd_resolve?
   - maybe drop the n_proc parameter to sd_resolve_new()?
   - change all functions to return int and negative errno errors
diff --git a/src/libsystemd/resolve-util.h b/src/libsystemd/resolve-util.h
index 4310f88..58df738 100644
--- a/src/libsystemd/resolve-util.h
+++ b/src/libsystemd/resolve-util.h
@@ -24,8 +24,6 @@
 #include util.h
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolve*, sd_resolve_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, sd_resolve_freeanswer);
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, sd_resolve_freeaddrinfo);
 #define _cleanup_resolve_free_ _cleanup_(sd_resolve_freep)
-#define _cleanup_resolve_answer_free_ _cleanup_(sd_resolve_freeanswerp)
 #define _cleanup_resolve_addrinfo_free_ _cleanup_(sd_resolve_freeaddrinfop)
diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index a368c1b..6958aa9 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -1105,17 +1105,6 @@ void sd_resolve_freeaddrinfo(struct addrinfo *ai) {
 errno = saved_errno;
 }
 
-void sd_resolve_freeanswer(unsigned char *answer) {
-int saved_errno = errno;
-
-if (!answer)
-return;
-
-free(answer);
-
-errno = saved_errno;
-}
-
 int sd_resolve_isdone(sd_resolve *resolve, sd_resolve_query*q) {
 assert(resolve);
 assert(q);
diff --git a/src/libsystemd/test-resolve.c b/src/libsystemd/test-resolve.c
index 7c1e7aa..3903e64 100644
--- a/src/libsystemd/test-resolve.c
+++ b/src/libsystemd/test-resolve.c
@@ -39,7 +39,7 @@ int main(int argc, char *argv[]) {
 int r = 1, ret;
 _cleanup_resolve_free_ sd_resolve *resolve = NULL;
 _cleanup_resolve_addrinfo_free_ struct addrinfo *ai = NULL;
-_cleanup_resolve_answer_free_ unsigned char *srv = NULL;
+_cleanup_free_ unsigned char *srv = NULL;
 sd_resolve_query *q1, *q2, *q3;
 struct addrinfo hints = {};
 struct sockaddr_in sa = {};
-- 
1.8.5.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 3/3] sd-resolve: rename get_next() and get_n_queries() + cleanup

2014-01-18 Thread Daniel Buch
---
 TODO| 1 -
 src/libsystemd/sd-resolve.c | 4 ++--
 src/systemd/sd-resolve.h| 9 +++--
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/TODO b/TODO
index 91a7bda..a842158 100644
--- a/TODO
+++ b/TODO
@@ -38,7 +38,6 @@ Features:
   - maybe simplify function calls that take a sd_resolve_query object, to not 
also require the matching sd_resolve?
   - maybe drop the n_proc parameter to sd_resolve_new()?
   - change all functions to return int and negative errno errors
-  - getnext and getnqueries should be renamed to get_next() and 
get_n_queries(), i.e. functions that are not modelled directly after the libc 
counterparts don't need to be a single word...
 
 * New service property: maximum CPU and wallclock runtime for a service
 
diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index 7cc8dc4..b6bf8d4 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -1043,12 +1043,12 @@ int sd_resolve_res_done(sd_resolve *resolve, 
sd_resolve_query* q, unsigned char
 return ret  0 ? -errno : ret;
 }
 
-sd_resolve_query* sd_resolve_getnext(sd_resolve *resolve) {
+sd_resolve_query* sd_resolve_get_next(sd_resolve *resolve) {
 assert(resolve);
 return resolve-done_head;
 }
 
-int sd_resolve_getnqueries(sd_resolve *resolve) {
+int sd_resolve_get_n_queries(sd_resolve *resolve) {
 assert(resolve);
 return resolve-n_queries;
 }
diff --git a/src/systemd/sd-resolve.h b/src/systemd/sd-resolve.h
index 8df6152..2779db0 100644
--- a/src/systemd/sd-resolve.h
+++ b/src/systemd/sd-resolve.h
@@ -63,7 +63,7 @@ void sd_resolve_free(sd_resolve *resolve);
 int sd_resolve_fd(sd_resolve *resolve);
 
 /** Process pending responses. After this function is called you can
- * get the next completed query object(s) using sd_resolve_getnext(). If
+ * get the next completed query object(s) using sd_resolve_get_next(). If
  * block is non-zero wait until at least one response has been
  * processed. If block is zero, process all pending responses and
  * return. */
@@ -124,11 +124,11 @@ int sd_resolve_res_done(sd_resolve *resolve, 
sd_resolve_query* q, unsigned char
 /** Return the next completed query object. If no query has been
  * completed yet, return NULL. Please note that you need to run
  * sd_resolve_wait() before this function will return sensible data.  */
-sd_resolve_query* sd_resolve_getnext(sd_resolve *resolve);
+sd_resolve_query* sd_resolve_get_next(sd_resolve *resolve);
 
 /** Return the number of query objects (completed or not) attached to
  * this session */
-int sd_resolve_getnqueries(sd_resolve *resolve);
+int sd_resolve_get_n_queries(sd_resolve *resolve);
 
 /** Cancel a currently running query. q is is destroyed by this call
  * and may not be used any futher. */
@@ -139,9 +139,6 @@ void sd_resolve_cancel(sd_resolve *resolve, 
sd_resolve_query* q);
  * of the libc's freeaddrinfo()! */
 void sd_resolve_freeaddrinfo(struct addrinfo *ai);
 
-/** Free the answer data as returned by sd_resolve_res_done().*/
-void sd_resolve_freeanswer(unsigned char *answer);
-
 /** Returns non-zero when the query operation specified by q has been 
completed */
 int sd_resolve_isdone(sd_resolve *resolve, sd_resolve_query*q);
 
-- 
1.8.5.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/4] sd-resolve: Allocate objects with new()

2014-01-18 Thread Daniel Buch
---
 src/libsystemd/sd-resolve.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index 6958aa9..7cc8dc4 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -423,7 +423,7 @@ sd_resolve* sd_resolve_new(unsigned n_proc) {
 if (n_proc  MAX_WORKERS)
 n_proc = MAX_WORKERS;
 
-resolve = malloc(sizeof(sd_resolve));
+resolve = new(sd_resolve, 1);
 if (!resolve) {
 errno = ENOMEM;
 goto fail;
@@ -562,7 +562,7 @@ static const void *unserialize_addrinfo(const void *p, 
struct addrinfo **ret_ai,
 if (*length  l)
 return NULL;
 
-ai = malloc(sizeof(struct addrinfo));
+ai = new(struct addrinfo, 1);
 if (!ai)
 goto fail;
 
@@ -765,7 +765,7 @@ static sd_resolve_query *alloc_query(sd_resolve *resolve) {
 resolve-current_index -= MAX_QUERIES;
 }
 
-q = resolve-queries[resolve-current_index] = 
malloc(sizeof(sd_resolve_query));
+q = resolve-queries[resolve-current_index] = new(sd_resolve_query, 
1);
 if (!q) {
 errno = ENOMEM;
 return NULL;
-- 
1.8.5.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 3/4] sd-resolve: rename get_next() and get_n_queries() + cleanup

2014-01-18 Thread Daniel Buch
---
 TODO| 1 -
 src/libsystemd/sd-resolve.c | 4 ++--
 src/systemd/sd-resolve.h| 9 +++--
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/TODO b/TODO
index 91a7bda..a842158 100644
--- a/TODO
+++ b/TODO
@@ -38,7 +38,6 @@ Features:
   - maybe simplify function calls that take a sd_resolve_query object, to not 
also require the matching sd_resolve?
   - maybe drop the n_proc parameter to sd_resolve_new()?
   - change all functions to return int and negative errno errors
-  - getnext and getnqueries should be renamed to get_next() and 
get_n_queries(), i.e. functions that are not modelled directly after the libc 
counterparts don't need to be a single word...
 
 * New service property: maximum CPU and wallclock runtime for a service
 
diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index 7cc8dc4..b6bf8d4 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -1043,12 +1043,12 @@ int sd_resolve_res_done(sd_resolve *resolve, 
sd_resolve_query* q, unsigned char
 return ret  0 ? -errno : ret;
 }
 
-sd_resolve_query* sd_resolve_getnext(sd_resolve *resolve) {
+sd_resolve_query* sd_resolve_get_next(sd_resolve *resolve) {
 assert(resolve);
 return resolve-done_head;
 }
 
-int sd_resolve_getnqueries(sd_resolve *resolve) {
+int sd_resolve_get_n_queries(sd_resolve *resolve) {
 assert(resolve);
 return resolve-n_queries;
 }
diff --git a/src/systemd/sd-resolve.h b/src/systemd/sd-resolve.h
index 8df6152..2779db0 100644
--- a/src/systemd/sd-resolve.h
+++ b/src/systemd/sd-resolve.h
@@ -63,7 +63,7 @@ void sd_resolve_free(sd_resolve *resolve);
 int sd_resolve_fd(sd_resolve *resolve);
 
 /** Process pending responses. After this function is called you can
- * get the next completed query object(s) using sd_resolve_getnext(). If
+ * get the next completed query object(s) using sd_resolve_get_next(). If
  * block is non-zero wait until at least one response has been
  * processed. If block is zero, process all pending responses and
  * return. */
@@ -124,11 +124,11 @@ int sd_resolve_res_done(sd_resolve *resolve, 
sd_resolve_query* q, unsigned char
 /** Return the next completed query object. If no query has been
  * completed yet, return NULL. Please note that you need to run
  * sd_resolve_wait() before this function will return sensible data.  */
-sd_resolve_query* sd_resolve_getnext(sd_resolve *resolve);
+sd_resolve_query* sd_resolve_get_next(sd_resolve *resolve);
 
 /** Return the number of query objects (completed or not) attached to
  * this session */
-int sd_resolve_getnqueries(sd_resolve *resolve);
+int sd_resolve_get_n_queries(sd_resolve *resolve);
 
 /** Cancel a currently running query. q is is destroyed by this call
  * and may not be used any futher. */
@@ -139,9 +139,6 @@ void sd_resolve_cancel(sd_resolve *resolve, 
sd_resolve_query* q);
  * of the libc's freeaddrinfo()! */
 void sd_resolve_freeaddrinfo(struct addrinfo *ai);
 
-/** Free the answer data as returned by sd_resolve_res_done().*/
-void sd_resolve_freeanswer(unsigned char *answer);
-
 /** Returns non-zero when the query operation specified by q has been 
completed */
 int sd_resolve_isdone(sd_resolve *resolve, sd_resolve_query*q);
 
-- 
1.8.5.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/4] sd-resolve: get rid of sd_resolve_freeanswer()

2014-01-18 Thread Daniel Buch
---
 TODO  |  1 -
 src/libsystemd/resolve-util.h |  2 --
 src/libsystemd/sd-resolve.c   | 11 ---
 src/libsystemd/test-resolve.c |  2 +-
 4 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/TODO b/TODO
index a567669..91a7bda 100644
--- a/TODO
+++ b/TODO
@@ -35,7 +35,6 @@ Features:
 * sd-resolve:
   - make sure event loop integration works similar to event loop integration 
in other libs
   - maybe drop _free() call, introduce _unref() instead
-  - sd_resolve_freeanswer() is probably pointless, we don't define such a 
function for any other return values, but expect people to call free directly
   - maybe simplify function calls that take a sd_resolve_query object, to not 
also require the matching sd_resolve?
   - maybe drop the n_proc parameter to sd_resolve_new()?
   - change all functions to return int and negative errno errors
diff --git a/src/libsystemd/resolve-util.h b/src/libsystemd/resolve-util.h
index 4310f88..58df738 100644
--- a/src/libsystemd/resolve-util.h
+++ b/src/libsystemd/resolve-util.h
@@ -24,8 +24,6 @@
 #include util.h
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolve*, sd_resolve_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, sd_resolve_freeanswer);
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, sd_resolve_freeaddrinfo);
 #define _cleanup_resolve_free_ _cleanup_(sd_resolve_freep)
-#define _cleanup_resolve_answer_free_ _cleanup_(sd_resolve_freeanswerp)
 #define _cleanup_resolve_addrinfo_free_ _cleanup_(sd_resolve_freeaddrinfop)
diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index a368c1b..6958aa9 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -1105,17 +1105,6 @@ void sd_resolve_freeaddrinfo(struct addrinfo *ai) {
 errno = saved_errno;
 }
 
-void sd_resolve_freeanswer(unsigned char *answer) {
-int saved_errno = errno;
-
-if (!answer)
-return;
-
-free(answer);
-
-errno = saved_errno;
-}
-
 int sd_resolve_isdone(sd_resolve *resolve, sd_resolve_query*q) {
 assert(resolve);
 assert(q);
diff --git a/src/libsystemd/test-resolve.c b/src/libsystemd/test-resolve.c
index 7c1e7aa..3903e64 100644
--- a/src/libsystemd/test-resolve.c
+++ b/src/libsystemd/test-resolve.c
@@ -39,7 +39,7 @@ int main(int argc, char *argv[]) {
 int r = 1, ret;
 _cleanup_resolve_free_ sd_resolve *resolve = NULL;
 _cleanup_resolve_addrinfo_free_ struct addrinfo *ai = NULL;
-_cleanup_resolve_answer_free_ unsigned char *srv = NULL;
+_cleanup_free_ unsigned char *srv = NULL;
 sd_resolve_query *q1, *q2, *q3;
 struct addrinfo hints = {};
 struct sockaddr_in sa = {};
-- 
1.8.5.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 4/4] sd-resolv: declare functions from .h public

2014-01-18 Thread Daniel Buch
---
 src/libsystemd/sd-resolve.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index b6bf8d4..464967b 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -414,7 +414,7 @@ static void* thread_worker(void *p) {
 return NULL;
 }
 
-sd_resolve* sd_resolve_new(unsigned n_proc) {
+_public_ sd_resolve* sd_resolve_new(unsigned n_proc) {
 sd_resolve *resolve = NULL;
 int i, r;
 
@@ -468,7 +468,7 @@ fail:
 return NULL;
 }
 
-void sd_resolve_free(sd_resolve *resolve) {
+_public_ void sd_resolve_free(sd_resolve *resolve) {
 int i;
 int saved_errno = errno;
 unsigned p;
@@ -511,7 +511,7 @@ void sd_resolve_free(sd_resolve *resolve) {
 errno = saved_errno;
 }
 
-int sd_resolve_fd(sd_resolve *resolve) {
+_public_ int sd_resolve_fd(sd_resolve *resolve) {
 assert(resolve);
 
 return resolve-fds[RESPONSE_RECV_FD];
@@ -709,7 +709,7 @@ static int handle_response(sd_resolve *resolve, const 
Packet *packet, size_t len
 return 0;
 }
 
-int sd_resolve_wait(sd_resolve *resolve, int block) {
+_public_ int sd_resolve_wait(sd_resolve *resolve, int block) {
 int handled = 0;
 assert(resolve);
 
@@ -787,7 +787,7 @@ static sd_resolve_query *alloc_query(sd_resolve *resolve) {
 return q;
 }
 
-sd_resolve_query* sd_resolve_getaddrinfo(sd_resolve *resolve, const char 
*node, const char *service, const struct addrinfo *hints) {
+_public_ sd_resolve_query* sd_resolve_getaddrinfo(sd_resolve *resolve, const 
char *node, const char *service, const struct addrinfo *hints) {
 AddrInfoRequest data[BUFSIZE/sizeof(AddrInfoRequest) + 1] = {};
 AddrInfoRequest *req = data;
 sd_resolve_query *q;
@@ -840,7 +840,7 @@ fail:
 return NULL;
 }
 
-int sd_resolve_getaddrinfo_done(sd_resolve *resolve, sd_resolve_query* q, 
struct addrinfo **ret_res) {
+_public_ int sd_resolve_getaddrinfo_done(sd_resolve *resolve, 
sd_resolve_query* q, struct addrinfo **ret_res) {
 int ret;
 assert(resolve);
 assert(q);
@@ -871,7 +871,7 @@ int sd_resolve_getaddrinfo_done(sd_resolve *resolve, 
sd_resolve_query* q, struct
 return ret;
 }
 
-sd_resolve_query* sd_resolve_getnameinfo(sd_resolve *resolve, const struct 
sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
+_public_ sd_resolve_query* sd_resolve_getnameinfo(sd_resolve *resolve, const 
struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
 NameInfoRequest data[BUFSIZE/sizeof(NameInfoRequest) + 1] = {};
 NameInfoRequest *req = data;
 sd_resolve_query *q;
@@ -917,7 +917,7 @@ fail:
 return NULL;
 }
 
-int sd_resolve_getnameinfo_done(sd_resolve *resolve, sd_resolve_query* q, char 
*ret_host, size_t hostlen, char *ret_serv, size_t servlen) {
+_public_ int sd_resolve_getnameinfo_done(sd_resolve *resolve, 
sd_resolve_query* q, char *ret_host, size_t hostlen, char *ret_serv, size_t 
servlen) {
 int ret;
 assert(resolve);
 assert(q);
@@ -1002,15 +1002,15 @@ fail:
 return NULL;
 }
 
-sd_resolve_query* sd_resolve_res_query(sd_resolve *resolve, const char *dname, 
int class, int type) {
+_public_ sd_resolve_query* sd_resolve_res_query(sd_resolve *resolve, const 
char *dname, int class, int type) {
 return resolve_res(resolve, REQUEST_RES_QUERY, dname, class, type);
 }
 
-sd_resolve_query* sd_resolve_res_search(sd_resolve *resolve, const char 
*dname, int class, int type) {
+_public_ sd_resolve_query* sd_resolve_res_search(sd_resolve *resolve, const 
char *dname, int class, int type) {
 return resolve_res(resolve, REQUEST_RES_SEARCH, dname, class, type);
 }
 
-int sd_resolve_res_done(sd_resolve *resolve, sd_resolve_query* q, unsigned 
char **answer) {
+_public_ int sd_resolve_res_done(sd_resolve *resolve, sd_resolve_query* q, 
unsigned char **answer) {
 int ret;
 assert(resolve);
 assert(q);
@@ -1043,17 +1043,17 @@ int sd_resolve_res_done(sd_resolve *resolve, 
sd_resolve_query* q, unsigned char
 return ret  0 ? -errno : ret;
 }
 
-sd_resolve_query* sd_resolve_get_next(sd_resolve *resolve) {
+_public_ sd_resolve_query* sd_resolve_get_next(sd_resolve *resolve) {
 assert(resolve);
 return resolve-done_head;
 }
 
-int sd_resolve_get_n_queries(sd_resolve *resolve) {
+_public_ int sd_resolve_get_n_queries(sd_resolve *resolve) {
 assert(resolve);
 return resolve-n_queries;
 }
 
-void sd_resolve_cancel(sd_resolve *resolve, sd_resolve_query* q) {
+_public_ void sd_resolve_cancel(sd_resolve *resolve, sd_resolve_query* q) {
 int i;
 int saved_errno = errno;
 
@@ -1089,7 +1089,7 @@ void sd_resolve_cancel(sd_resolve *resolve, 
sd_resolve_query* q) {
 errno = saved_errno;
 }
 
-void sd_resolve_freeaddrinfo(struct addrinfo *ai) {

[systemd-devel] [PATCH 1/2] sd-resolve: get rid of _t post-fixes for sd_ objects

2014-01-15 Thread Daniel Buch
We dont want _t prefixes, right?

---
 src/libsystemd/resolve-util.h |  2 +-
 src/libsystemd/sd-resolve.c   | 72 +--
 src/libsystemd/test-resolve.c |  4 +--
 src/systemd/sd-resolve.h  | 42 -
 4 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/src/libsystemd/resolve-util.h b/src/libsystemd/resolve-util.h
index 0761c96..4310f88 100644
--- a/src/libsystemd/resolve-util.h
+++ b/src/libsystemd/resolve-util.h
@@ -23,7 +23,7 @@
 
 #include util.h
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolve_t*, sd_resolve_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolve*, sd_resolve_free);
 DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, sd_resolve_freeanswer);
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, sd_resolve_freeaddrinfo);
 #define _cleanup_resolve_free_ _cleanup_(sd_resolve_freep)
diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index 269f517..73a66c4 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -75,20 +75,20 @@ struct sd_resolve {
 unsigned valid_workers;
 
 unsigned current_id, current_index;
-sd_resolve_query_t* queries[MAX_QUERIES];
+sd_resolve_query* queries[MAX_QUERIES];
 
-sd_resolve_query_t *done_head, *done_tail;
+sd_resolve_query *done_head, *done_tail;
 
 int n_queries;
 int dead;
 };
 
 struct sd_resolve_query {
-sd_resolve_t *resolve;
+sd_resolve *resolve;
 int done;
 unsigned id;
 query_type_t type;
-sd_resolve_query_t *done_next, *done_prev;
+sd_resolve_query *done_next, *done_prev;
 int ret;
 int _errno;
 int _h_errno;
@@ -383,7 +383,7 @@ static int handle_request(int out_fd, const packet_t 
*packet, size_t length) {
 }
 
 static void* thread_worker(void *p) {
-sd_resolve_t *resolve = p;
+sd_resolve *resolve = p;
 sigset_t fullset;
 
 /* No signals in this thread please */
@@ -414,8 +414,8 @@ static void* thread_worker(void *p) {
 return NULL;
 }
 
-sd_resolve_t* sd_resolve_new(unsigned n_proc) {
-sd_resolve_t *resolve = NULL;
+sd_resolve* sd_resolve_new(unsigned n_proc) {
+sd_resolve *resolve = NULL;
 int i, r;
 
 assert(n_proc = 1);
@@ -423,7 +423,7 @@ sd_resolve_t* sd_resolve_new(unsigned n_proc) {
 if (n_proc  MAX_WORKERS)
 n_proc = MAX_WORKERS;
 
-resolve = malloc(sizeof(sd_resolve_t));
+resolve = malloc(sizeof(sd_resolve));
 if (!resolve) {
 errno = ENOMEM;
 goto fail;
@@ -468,7 +468,7 @@ fail:
 return NULL;
 }
 
-void sd_resolve_free(sd_resolve_t *resolve) {
+void sd_resolve_free(sd_resolve *resolve) {
 int i;
 int saved_errno = errno;
 unsigned p;
@@ -511,14 +511,14 @@ void sd_resolve_free(sd_resolve_t *resolve) {
 errno = saved_errno;
 }
 
-int sd_resolve_fd(sd_resolve_t *resolve) {
+int sd_resolve_fd(sd_resolve *resolve) {
 assert(resolve);
 
 return resolve-fds[RESPONSE_RECV_FD];
 }
 
-static sd_resolve_query_t *lookup_query(sd_resolve_t *resolve, unsigned id) {
-sd_resolve_query_t *q;
+static sd_resolve_query *lookup_query(sd_resolve *resolve, unsigned id) {
+sd_resolve_query *q;
 assert(resolve);
 
 q = resolve-queries[id % MAX_QUERIES];
@@ -529,7 +529,7 @@ static sd_resolve_query_t *lookup_query(sd_resolve_t 
*resolve, unsigned id) {
 return NULL;
 }
 
-static void complete_query(sd_resolve_t *resolve, sd_resolve_query_t *q) {
+static void complete_query(sd_resolve *resolve, sd_resolve_query *q) {
 assert(resolve);
 assert(q);
 assert(!q-done);
@@ -601,9 +601,9 @@ fail:
 return NULL;
 }
 
-static int handle_response(sd_resolve_t *resolve, const packet_t *packet, 
size_t length) {
+static int handle_response(sd_resolve *resolve, const packet_t *packet, size_t 
length) {
 const rheader_t *resp;
-sd_resolve_query_t *q;
+sd_resolve_query *q;
 
 assert(resolve);
 
@@ -709,7 +709,7 @@ static int handle_response(sd_resolve_t *resolve, const 
packet_t *packet, size_t
 return 0;
 }
 
-int sd_resolve_wait(sd_resolve_t *resolve, int block) {
+int sd_resolve_wait(sd_resolve *resolve, int block) {
 int handled = 0;
 assert(resolve);
 
@@ -748,8 +748,8 @@ int sd_resolve_wait(sd_resolve_t *resolve, int block) {
 }
 }
 
-static sd_resolve_query_t *alloc_query(sd_resolve_t *resolve) {
-sd_resolve_query_t *q;
+static sd_resolve_query *alloc_query(sd_resolve *resolve) {
+sd_resolve_query *q;
 assert(resolve);
 
 if (resolve-n_queries = MAX_QUERIES) {
@@ -765,7 +765,7 @@ static sd_resolve_query_t *alloc_query(sd_resolve_t 
*resolve) {
 resolve-current_index -= MAX_QUERIES;
 }
 
-q = resolve-queries[resolve-current_index] = 

[systemd-devel] [PATCH 2/2][RFC] sd-resolve: rename structs to fit coding-style e.g 'struct MixedCase'

2014-01-15 Thread Daniel Buch
lets get this right once, and if not for all, atleast for now :)

So comments and input about nameing is very welcome.

Cheers

---
 src/libsystemd/sd-resolve.c | 210 ++--
 1 file changed, 105 insertions(+), 105 deletions(-)

diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index 73a66c4..a368c1b 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -58,7 +58,7 @@ typedef enum {
 RESPONSE_RES,
 REQUEST_TERMINATE,
 RESPONSE_DIED
-} query_type_t;
+} QueryType;
 
 enum {
 REQUEST_RECV_FD = 0,
@@ -87,7 +87,7 @@ struct sd_resolve_query {
 sd_resolve *resolve;
 int done;
 unsigned id;
-query_type_t type;
+QueryType type;
 sd_resolve_query *done_next, *done_prev;
 int ret;
 int _errno;
@@ -97,31 +97,31 @@ struct sd_resolve_query {
 void *userdata;
 };
 
-typedef struct rheader {
-query_type_t type;
+typedef struct RHeader {
+QueryType type;
 unsigned id;
 size_t length;
-} rheader_t;
+} RHeader;
 
-typedef struct addrinfo_request {
-struct rheader header;
+typedef struct AddrInfoRequest {
+struct RHeader header;
 int hints_is_null;
 int ai_flags;
 int ai_family;
 int ai_socktype;
 int ai_protocol;
 size_t node_len, service_len;
-} addrinfo_request_t;
+} AddrInfoRequest;
 
-typedef struct addrinfo_response {
-struct rheader header;
+typedef struct AddrInfoResponse {
+struct RHeader header;
 int ret;
 int _errno;
 int _h_errno;
 /* followed by addrinfo_serialization[] */
-} addrinfo_response_t;
+} AddrInfoResponse;
 
-typedef struct addrinfo_serialization {
+typedef struct AddrInfoSerialization {
 int ai_flags;
 int ai_family;
 int ai_socktype;
@@ -129,49 +129,49 @@ typedef struct addrinfo_serialization {
 size_t ai_addrlen;
 size_t canonname_len;
 /* Followed by ai_addr amd ai_canonname with variable lengths */
-} addrinfo_serialization_t;
+} AddrInfoSerialization;
 
-typedef struct nameinfo_request {
-struct rheader header;
+typedef struct NameInfoRequest {
+struct RHeader header;
 int flags;
 socklen_t sockaddr_len;
 int gethost, getserv;
-} nameinfo_request_t;
+} NameInfoRequest;
 
-typedef struct nameinfo_response {
-struct rheader header;
+typedef struct NameInfoResponse {
+struct RHeader header;
 size_t hostlen, servlen;
 int ret;
 int _errno;
 int _h_errno;
-} nameinfo_response_t;
+} NameInfoResponse;
 
-typedef struct res_request {
-struct rheader header;
+typedef struct ResRequest {
+struct RHeader header;
 int class;
 int type;
 size_t dname_len;
-} res_request_t;
+} ResRequest;
 
-typedef struct res_response {
-struct rheader header;
+typedef struct ResResponse {
+struct RHeader header;
 int ret;
 int _errno;
 int _h_errno;
-} res_response_t;
-
-typedef union packet {
-rheader_t rheader;
-addrinfo_request_t addrinfo_request;
-addrinfo_response_t addrinfo_response;
-nameinfo_request_t nameinfo_request;
-nameinfo_response_t nameinfo_response;
-res_request_t res_request;
-res_response_t res_response;
-} packet_t;
+} ResResponse;
+
+typedef union Packet {
+RHeader rheader;
+AddrInfoRequest addrinfo_request;
+AddrInfoResponse addrinfo_response;
+NameInfoRequest nameinfo_request;
+NameInfoResponse nameinfo_response;
+ResRequest res_request;
+ResResponse res_response;
+} Packet;
 
 static int send_died(int out_fd) {
-rheader_t rh = {};
+RHeader rh = {};
 assert(out_fd  0);
 
 rh.type = RESPONSE_DIED;
@@ -182,7 +182,7 @@ static int send_died(int out_fd) {
 }
 
 static void *serialize_addrinfo(void *p, const struct addrinfo *ai, size_t 
*length, size_t maxlength) {
-addrinfo_serialization_t s;
+AddrInfoSerialization s;
 size_t cnl, l;
 assert(p);
 assert(ai);
@@ -190,7 +190,7 @@ static void *serialize_addrinfo(void *p, const struct 
addrinfo *ai, size_t *leng
 assert(*length = maxlength);
 
 cnl = (ai-ai_canonname ? strlen(ai-ai_canonname)+1 : 0);
-l = sizeof(addrinfo_serialization_t) + ai-ai_addrlen + cnl;
+l = sizeof(AddrInfoSerialization) + ai-ai_addrlen + cnl;
 
 if (*length + l  maxlength)
 return NULL;
@@ -202,24 +202,24 @@ static void *serialize_addrinfo(void *p, const struct 
addrinfo *ai, size_t *leng
 s.ai_addrlen = ai-ai_addrlen;
 s.canonname_len = cnl;
 
-memcpy((uint8_t*) p, s, sizeof(addrinfo_serialization_t));
-memcpy((uint8_t*) p + sizeof(addrinfo_serialization_t), ai-ai_addr, 

[systemd-devel] [PATCH 1/2] sd_resolv: Rename structs- and function names to sd_resolv

2014-01-14 Thread Daniel Buch
---
 src/libsystemd/resolv-util.h |  12 +++---
 src/libsystemd/sd-resolv.c   | 100 +--
 src/libsystemd/test-resolv.c |  38 
 src/systemd/sd-resolv.h  |  80 +-
 4 files changed, 115 insertions(+), 115 deletions(-)

diff --git a/src/libsystemd/resolv-util.h b/src/libsystemd/resolv-util.h
index e0284c8..7b6ec70 100644
--- a/src/libsystemd/resolv-util.h
+++ b/src/libsystemd/resolv-util.h
@@ -23,9 +23,9 @@
 
 #include util.h
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(asyncns_t*, asyncns_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, asyncns_freeanswer);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, asyncns_freeaddrinfo);
-#define _cleanup_asyncns_free_ _cleanup_(asyncns_freep)
-#define _cleanup_asyncns_answer_free_ _cleanup_(asyncns_freeanswerp)
-#define _cleanup_asyncns_addrinfo_free_ _cleanup_(asyncns_freeaddrinfop)
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolv_t*, sd_resolv_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, sd_resolv_freeanswer);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, sd_resolv_freeaddrinfo);
+#define _cleanup_resolv_free_ _cleanup_(sd_resolv_freep)
+#define _cleanup_resolv_answer_free_ _cleanup_(sd_resolv_freeanswerp)
+#define _cleanup_resolv_addrinfo_free_ _cleanup_(sd_resolv_freeaddrinfop)
diff --git a/src/libsystemd/sd-resolv.c b/src/libsystemd/sd-resolv.c
index 2db66eb..a4e7cde 100644
--- a/src/libsystemd/sd-resolv.c
+++ b/src/libsystemd/sd-resolv.c
@@ -68,27 +68,27 @@ enum {
 MESSAGE_FD_MAX = 4
 };
 
-struct asyncns {
+struct sd_resolv {
 int fds[MESSAGE_FD_MAX];
 
 pthread_t workers[MAX_WORKERS];
 unsigned valid_workers;
 
 unsigned current_id, current_index;
-asyncns_query_t* queries[MAX_QUERIES];
+sd_resolv_query_t* queries[MAX_QUERIES];
 
-asyncns_query_t *done_head, *done_tail;
+sd_resolv_query_t *done_head, *done_tail;
 
 int n_queries;
 int dead;
 };
 
-struct asyncns_query {
-asyncns_t *asyncns;
+struct sd_resolv_query {
+sd_resolv_t *asyncns;
 int done;
 unsigned id;
 query_type_t type;
-asyncns_query_t *done_next, *done_prev;
+sd_resolv_query_t *done_next, *done_prev;
 int ret;
 int _errno;
 int _h_errno;
@@ -383,7 +383,7 @@ static int handle_request(int out_fd, const packet_t 
*packet, size_t length) {
 }
 
 static void* thread_worker(void *p) {
-asyncns_t *asyncns = p;
+sd_resolv_t *asyncns = p;
 sigset_t fullset;
 
 /* No signals in this thread please */
@@ -414,16 +414,16 @@ static void* thread_worker(void *p) {
 return NULL;
 }
 
-asyncns_t* asyncns_new(unsigned n_proc) {
+sd_resolv_t* sd_resolv_new(unsigned n_proc) {
 int i;
-asyncns_t *asyncns = NULL;
+sd_resolv_t *asyncns = NULL;
 
 assert(n_proc = 1);
 
 if (n_proc  MAX_WORKERS)
 n_proc = MAX_WORKERS;
 
-asyncns = malloc(sizeof(asyncns_t));
+asyncns = malloc(sizeof(sd_resolv_t));
 if (!asyncns) {
 errno = ENOMEM;
 goto fail;
@@ -475,12 +475,12 @@ asyncns_t* asyncns_new(unsigned n_proc) {
 
 fail:
 if (asyncns)
-asyncns_free(asyncns);
+sd_resolv_free(asyncns);
 
 return NULL;
 }
 
-void asyncns_free(asyncns_t *asyncns) {
+void sd_resolv_free(sd_resolv_t *asyncns) {
 int i;
 int saved_errno = errno;
 unsigned p;
@@ -516,21 +516,21 @@ void asyncns_free(asyncns_t *asyncns) {
 
 for (p = 0; p  MAX_QUERIES; p++)
 if (asyncns-queries[p])
-asyncns_cancel(asyncns, asyncns-queries[p]);
+sd_resolv_cancel(asyncns, asyncns-queries[p]);
 
 free(asyncns);
 
 errno = saved_errno;
 }
 
-int asyncns_fd(asyncns_t *asyncns) {
+int sd_resolv_fd(sd_resolv_t *asyncns) {
 assert(asyncns);
 
 return asyncns-fds[RESPONSE_RECV_FD];
 }
 
-static asyncns_query_t *lookup_query(asyncns_t *asyncns, unsigned id) {
-asyncns_query_t *q;
+static sd_resolv_query_t *lookup_query(sd_resolv_t *asyncns, unsigned id) {
+sd_resolv_query_t *q;
 assert(asyncns);
 
 q = asyncns-queries[id % MAX_QUERIES];
@@ -541,7 +541,7 @@ static asyncns_query_t *lookup_query(asyncns_t *asyncns, 
unsigned id) {
 return NULL;
 }
 
-static void complete_query(asyncns_t *asyncns, asyncns_query_t *q) {
+static void complete_query(sd_resolv_t *asyncns, sd_resolv_query_t *q) {
 assert(asyncns);
 assert(q);
 assert(!q-done);
@@ -608,14 +608,14 @@ static const void *unserialize_addrinfo(const void *p, 
struct addrinfo **ret_ai,
 
 fail:
 if (ai)
-asyncns_freeaddrinfo(ai);
+sd_resolv_freeaddrinfo(ai);
 
 return NULL;
 }
 
-static int handle_response(asyncns_t *asyncns, const packet_t *packet, size_t 

[systemd-devel] [PATCH 2/2] sd-resolv: rename old asyncns variables

2014-01-14 Thread Daniel Buch
---
 src/libsystemd/sd-resolv.c   | 282 +--
 src/libsystemd/test-resolv.c |  26 ++--
 src/systemd/sd-resolv.h  |  48 
 3 files changed, 178 insertions(+), 178 deletions(-)

diff --git a/src/libsystemd/sd-resolv.c b/src/libsystemd/sd-resolv.c
index a4e7cde..aa97ef7 100644
--- a/src/libsystemd/sd-resolv.c
+++ b/src/libsystemd/sd-resolv.c
@@ -84,7 +84,7 @@ struct sd_resolv {
 };
 
 struct sd_resolv_query {
-sd_resolv_t *asyncns;
+sd_resolv_t *resolv;
 int done;
 unsigned id;
 query_type_t type;
@@ -383,18 +383,18 @@ static int handle_request(int out_fd, const packet_t 
*packet, size_t length) {
 }
 
 static void* thread_worker(void *p) {
-sd_resolv_t *asyncns = p;
+sd_resolv_t *resolv = p;
 sigset_t fullset;
 
 /* No signals in this thread please */
 sigfillset(fullset);
 pthread_sigmask(SIG_BLOCK, fullset, NULL);
 
-while (!asyncns-dead) {
+while (!resolv-dead) {
 packet_t buf[BUFSIZE/sizeof(packet_t) + 1];
 ssize_t length;
 
-length = recv(asyncns-fds[REQUEST_RECV_FD], buf, sizeof(buf), 
0);
+length = recv(resolv-fds[REQUEST_RECV_FD], buf, sizeof(buf), 
0);
 
 if (length = 0) {
 if (length  0  (errno == EAGAIN || errno == EINTR))
@@ -402,50 +402,50 @@ static void* thread_worker(void *p) {
 break;
 }
 
-if (asyncns-dead)
+if (resolv-dead)
 break;
 
-if (handle_request(asyncns-fds[RESPONSE_SEND_FD], buf, 
(size_t) length)  0)
+if (handle_request(resolv-fds[RESPONSE_SEND_FD], buf, 
(size_t) length)  0)
 break;
 }
 
-send_died(asyncns-fds[RESPONSE_SEND_FD]);
+send_died(resolv-fds[RESPONSE_SEND_FD]);
 
 return NULL;
 }
 
 sd_resolv_t* sd_resolv_new(unsigned n_proc) {
 int i;
-sd_resolv_t *asyncns = NULL;
+sd_resolv_t *resolv = NULL;
 
 assert(n_proc = 1);
 
 if (n_proc  MAX_WORKERS)
 n_proc = MAX_WORKERS;
 
-asyncns = malloc(sizeof(sd_resolv_t));
-if (!asyncns) {
+resolv = malloc(sizeof(sd_resolv_t));
+if (!resolv) {
 errno = ENOMEM;
 goto fail;
 }
 
-asyncns-dead = 0;
-asyncns-valid_workers = 0;
+resolv-dead = 0;
+resolv-valid_workers = 0;
 
 for (i = 0; i  MESSAGE_FD_MAX; i++)
-asyncns-fds[i] = -1;
+resolv-fds[i] = -1;
 
-memset(asyncns-queries, 0, sizeof(asyncns-queries));
+memset(resolv-queries, 0, sizeof(resolv-queries));
 
 #ifdef SOCK_CLOEXEC
-if (socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, asyncns-fds)  0 
||
-socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, 
asyncns-fds+2)  0) {
+if (socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, resolv-fds)  0 ||
+socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, 
resolv-fds+2)  0) {
 
 /* Try again, without SOCK_CLOEXEC */
 if (errno == EINVAL) {
 #endif
-if (socketpair(PF_UNIX, SOCK_DGRAM, 0, asyncns-fds)  
0 ||
-socketpair(PF_UNIX, SOCK_DGRAM, 0, 
asyncns-fds+2)  0)
+if (socketpair(PF_UNIX, SOCK_DGRAM, 0, resolv-fds)  
0 ||
+socketpair(PF_UNIX, SOCK_DGRAM, 0, 
resolv-fds+2)  0)
 goto fail;
 #ifdef SOCK_CLOEXEC
 } else
@@ -454,42 +454,42 @@ sd_resolv_t* sd_resolv_new(unsigned n_proc) {
 #endif
 
 for (i = 0; i  MESSAGE_FD_MAX; i++)
-fd_cloexec(asyncns-fds[i], true);
+fd_cloexec(resolv-fds[i], true);
 
-for (asyncns-valid_workers = 0; asyncns-valid_workers  n_proc; 
asyncns-valid_workers++) {
+for (resolv-valid_workers = 0; resolv-valid_workers  n_proc; 
resolv-valid_workers++) {
 int r;
-r = pthread_create(asyncns-workers[asyncns-valid_workers], 
NULL, thread_worker, asyncns);
+r = pthread_create(resolv-workers[resolv-valid_workers], 
NULL, thread_worker, resolv);
 if (r) {
 errno = r;
 goto fail;
 }
 }
 
-asyncns-current_index = asyncns-current_id = 0;
-asyncns-done_head = asyncns-done_tail = NULL;
-asyncns-n_queries = 0;
+resolv-current_index = resolv-current_id = 0;
+resolv-done_head = resolv-done_tail = NULL;
+resolv-n_queries = 0;
 
-fd_nonblock(asyncns-fds[RESPONSE_RECV_FD], true);
+fd_nonblock(resolv-fds[RESPONSE_RECV_FD], true);
 
-return asyncns;
+return resolv;
 
 fail:
-   

[systemd-devel] [PATCH] sd-resolv: declare functions from .h public

2014-01-14 Thread Daniel Buch
---
 src/libsystemd/sd-resolv.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/libsystemd/sd-resolv.c b/src/libsystemd/sd-resolv.c
index b8288ba..cd79a6c 100644
--- a/src/libsystemd/sd-resolv.c
+++ b/src/libsystemd/sd-resolv.c
@@ -414,7 +414,7 @@ static void* thread_worker(void *p) {
 return NULL;
 }
 
-sd_resolv_t* sd_resolv_new(unsigned n_proc) {
+_public_ sd_resolv_t* sd_resolv_new(unsigned n_proc) {
 sd_resolv_t *resolv = NULL;
 int i, r;
 
@@ -468,7 +468,7 @@ fail:
 return NULL;
 }
 
-void sd_resolv_free(sd_resolv_t *resolv) {
+_public_ void sd_resolv_free(sd_resolv_t *resolv) {
 int i;
 int saved_errno = errno;
 unsigned p;
@@ -511,7 +511,7 @@ void sd_resolv_free(sd_resolv_t *resolv) {
 errno = saved_errno;
 }
 
-int sd_resolv_fd(sd_resolv_t *resolv) {
+_public_ int sd_resolv_fd(sd_resolv_t *resolv) {
 assert(resolv);
 
 return resolv-fds[RESPONSE_RECV_FD];
@@ -709,7 +709,7 @@ static int handle_response(sd_resolv_t *resolv, const 
packet_t *packet, size_t l
 return 0;
 }
 
-int sd_resolv_wait(sd_resolv_t *resolv, int block) {
+_public_ int sd_resolv_wait(sd_resolv_t *resolv, int block) {
 int handled = 0;
 assert(resolv);
 
@@ -787,7 +787,7 @@ static sd_resolv_query_t *alloc_query(sd_resolv_t *resolv) {
 return q;
 }
 
-sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *resolv, const char 
*node, const char *service, const struct addrinfo *hints) {
+_public_ sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *resolv, const 
char *node, const char *service, const struct addrinfo *hints) {
 addrinfo_request_t data[BUFSIZE/sizeof(addrinfo_request_t) + 1] = {};
 addrinfo_request_t *req = data;
 sd_resolv_query_t *q;
@@ -840,7 +840,7 @@ fail:
 return NULL;
 }
 
-int sd_resolv_getaddrinfo_done(sd_resolv_t *resolv, sd_resolv_query_t* q, 
struct addrinfo **ret_res) {
+_public_ int sd_resolv_getaddrinfo_done(sd_resolv_t *resolv, 
sd_resolv_query_t* q, struct addrinfo **ret_res) {
 int ret;
 assert(resolv);
 assert(q);
@@ -871,7 +871,7 @@ int sd_resolv_getaddrinfo_done(sd_resolv_t *resolv, 
sd_resolv_query_t* q, struct
 return ret;
 }
 
-sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *resolv, const struct 
sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
+_public_ sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *resolv, const 
struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
 nameinfo_request_t data[BUFSIZE/sizeof(nameinfo_request_t) + 1] = {};
 nameinfo_request_t *req = data;
 sd_resolv_query_t *q;
@@ -917,7 +917,7 @@ fail:
 return NULL;
 }
 
-int sd_resolv_getnameinfo_done(sd_resolv_t *resolv, sd_resolv_query_t* q, char 
*ret_host, size_t hostlen, char *ret_serv, size_t servlen) {
+_public_ int sd_resolv_getnameinfo_done(sd_resolv_t *resolv, 
sd_resolv_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t 
servlen) {
 int ret;
 assert(resolv);
 assert(q);
@@ -1002,15 +1002,15 @@ fail:
 return NULL;
 }
 
-sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *resolv, const char *dname, 
int class, int type) {
+_public_ sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *resolv, const 
char *dname, int class, int type) {
 return resolv_res(resolv, REQUEST_RES_QUERY, dname, class, type);
 }
 
-sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *resolv, const char 
*dname, int class, int type) {
+_public_ sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *resolv, const 
char *dname, int class, int type) {
 return resolv_res(resolv, REQUEST_RES_SEARCH, dname, class, type);
 }
 
-int sd_resolv_res_done(sd_resolv_t *resolv, sd_resolv_query_t* q, unsigned 
char **answer) {
+_public_ int sd_resolv_res_done(sd_resolv_t *resolv, sd_resolv_query_t* q, 
unsigned char **answer) {
 int ret;
 assert(resolv);
 assert(q);
@@ -1043,17 +1043,17 @@ int sd_resolv_res_done(sd_resolv_t *resolv, 
sd_resolv_query_t* q, unsigned char
 return ret  0 ? -errno : ret;
 }
 
-sd_resolv_query_t* sd_resolv_getnext(sd_resolv_t *resolv) {
+_public_ sd_resolv_query_t* sd_resolv_getnext(sd_resolv_t *resolv) {
 assert(resolv);
 return resolv-done_head;
 }
 
-int sd_resolv_getnqueries(sd_resolv_t *resolv) {
+_public_ int sd_resolv_getnqueries(sd_resolv_t *resolv) {
 assert(resolv);
 return resolv-n_queries;
 }
 
-void sd_resolv_cancel(sd_resolv_t *resolv, sd_resolv_query_t* q) {
+_public_ void sd_resolv_cancel(sd_resolv_t *resolv, sd_resolv_query_t* q) {
 int i;
 int saved_errno = errno;
 
@@ -1089,7 +1089,7 @@ void sd_resolv_cancel(sd_resolv_t *resolv, 
sd_resolv_query_t* q) {
 errno = saved_errno;
 }
 
-void sd_resolv_freeaddrinfo(struct addrinfo *ai) {
+_public_ 

Re: [systemd-devel] [PATCH] sd-resolv: declare functions from .h public

2014-01-14 Thread Daniel Buch
Hi,

I'm perfectly fine if we skip this patch, and to my understanding there is
no benefits and only corresponds to external linkage.


2014/1/14 Tom Gundersen t...@jklm.no

 Hi Daniel,

 I guess we should only do this once we decide to export the API. I
 guess we won't be doing that for a few releases (we'll use it
 internally first to make sure it is the way we want it).

 Or are there any benefits to these annotations even when the symbols
 are not exported?

 -t

 On Tue, Jan 14, 2014 at 3:04 PM, Daniel Buch boogiewasth...@gmail.com
 wrote:
  ---
   src/libsystemd/sd-resolv.c | 38 +++---
   1 file changed, 19 insertions(+), 19 deletions(-)
 
  diff --git a/src/libsystemd/sd-resolv.c b/src/libsystemd/sd-resolv.c
  index b8288ba..cd79a6c 100644
  --- a/src/libsystemd/sd-resolv.c
  +++ b/src/libsystemd/sd-resolv.c
  @@ -414,7 +414,7 @@ static void* thread_worker(void *p) {
   return NULL;
   }
 
  -sd_resolv_t* sd_resolv_new(unsigned n_proc) {
  +_public_ sd_resolv_t* sd_resolv_new(unsigned n_proc) {
   sd_resolv_t *resolv = NULL;
   int i, r;
 
  @@ -468,7 +468,7 @@ fail:
   return NULL;
   }
 
  -void sd_resolv_free(sd_resolv_t *resolv) {
  +_public_ void sd_resolv_free(sd_resolv_t *resolv) {
   int i;
   int saved_errno = errno;
   unsigned p;
  @@ -511,7 +511,7 @@ void sd_resolv_free(sd_resolv_t *resolv) {
   errno = saved_errno;
   }
 
  -int sd_resolv_fd(sd_resolv_t *resolv) {
  +_public_ int sd_resolv_fd(sd_resolv_t *resolv) {
   assert(resolv);
 
   return resolv-fds[RESPONSE_RECV_FD];
  @@ -709,7 +709,7 @@ static int handle_response(sd_resolv_t *resolv,
 const packet_t *packet, size_t l
   return 0;
   }
 
  -int sd_resolv_wait(sd_resolv_t *resolv, int block) {
  +_public_ int sd_resolv_wait(sd_resolv_t *resolv, int block) {
   int handled = 0;
   assert(resolv);
 
  @@ -787,7 +787,7 @@ static sd_resolv_query_t *alloc_query(sd_resolv_t
 *resolv) {
   return q;
   }
 
  -sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *resolv, const
 char *node, const char *service, const struct addrinfo *hints) {
  +_public_ sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *resolv,
 const char *node, const char *service, const struct addrinfo *hints) {
   addrinfo_request_t data[BUFSIZE/sizeof(addrinfo_request_t) + 1]
 = {};
   addrinfo_request_t *req = data;
   sd_resolv_query_t *q;
  @@ -840,7 +840,7 @@ fail:
   return NULL;
   }
 
  -int sd_resolv_getaddrinfo_done(sd_resolv_t *resolv, sd_resolv_query_t*
 q, struct addrinfo **ret_res) {
  +_public_ int sd_resolv_getaddrinfo_done(sd_resolv_t *resolv,
 sd_resolv_query_t* q, struct addrinfo **ret_res) {
   int ret;
   assert(resolv);
   assert(q);
  @@ -871,7 +871,7 @@ int sd_resolv_getaddrinfo_done(sd_resolv_t *resolv,
 sd_resolv_query_t* q, struct
   return ret;
   }
 
  -sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *resolv, const
 struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
  +_public_ sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *resolv,
 const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int
 getserv) {
   nameinfo_request_t data[BUFSIZE/sizeof(nameinfo_request_t) + 1]
 = {};
   nameinfo_request_t *req = data;
   sd_resolv_query_t *q;
  @@ -917,7 +917,7 @@ fail:
   return NULL;
   }
 
  -int sd_resolv_getnameinfo_done(sd_resolv_t *resolv, sd_resolv_query_t*
 q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen) {
  +_public_ int sd_resolv_getnameinfo_done(sd_resolv_t *resolv,
 sd_resolv_query_t* q, char *ret_host, size_t hostlen, char *ret_serv,
 size_t servlen) {
   int ret;
   assert(resolv);
   assert(q);
  @@ -1002,15 +1002,15 @@ fail:
   return NULL;
   }
 
  -sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *resolv, const char
 *dname, int class, int type) {
  +_public_ sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *resolv,
 const char *dname, int class, int type) {
   return resolv_res(resolv, REQUEST_RES_QUERY, dname, class,
 type);
   }
 
  -sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *resolv, const char
 *dname, int class, int type) {
  +_public_ sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *resolv,
 const char *dname, int class, int type) {
   return resolv_res(resolv, REQUEST_RES_SEARCH, dname, class,
 type);
   }
 
  -int sd_resolv_res_done(sd_resolv_t *resolv, sd_resolv_query_t* q,
 unsigned char **answer) {
  +_public_ int sd_resolv_res_done(sd_resolv_t *resolv, sd_resolv_query_t*
 q, unsigned char **answer) {
   int ret;
   assert(resolv);
   assert(q);
  @@ -1043,17 +1043,17 @@ int sd_resolv_res_done(sd_resolv_t *resolv,
 sd_resolv_query_t* q, unsigned char
   return ret  0 ? -errno : ret;
   }
 
  -sd_resolv_query_t

Re: [systemd-devel] [PATCH 2/2] sd-dns: rename structs and functions with sd_ prefix

2014-01-13 Thread Daniel Buch
Ohh.. that sounds reasonable, i can do the git mv and renameig (And squash
to a single commit) when the decision is set :)


2014/1/13 Tom Gundersen t...@jklm.no

 On Mon, Jan 13, 2014 at 8:56 AM, Daniel Buch boogiewasth...@gmail.com
 wrote:
  Okay, guess thats right? Second opinion, lennart? Kay?

 Yeah, wait a bit with the rename until we have some more feedback,
 just heard a suggestion from Kay of calling it sd-resolv instead
 (which sounds good to me).

 -t

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/2] sd-dns: rename structs and functions with sd_ prefix

2014-01-12 Thread Daniel Buch
---
 src/libsystemd-bus/dns-util.h |  12 ++---
 src/libsystemd-bus/sd-dns.c   | 100 +-
 src/libsystemd-bus/test-dns.c |  26 +--
 src/systemd/sd-dns.h  |  46 +--
 4 files changed, 92 insertions(+), 92 deletions(-)

diff --git a/src/libsystemd-bus/dns-util.h b/src/libsystemd-bus/dns-util.h
index e0284c8..15ab28b 100644
--- a/src/libsystemd-bus/dns-util.h
+++ b/src/libsystemd-bus/dns-util.h
@@ -23,9 +23,9 @@
 
 #include util.h
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(asyncns_t*, asyncns_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, asyncns_freeanswer);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, asyncns_freeaddrinfo);
-#define _cleanup_asyncns_free_ _cleanup_(asyncns_freep)
-#define _cleanup_asyncns_answer_free_ _cleanup_(asyncns_freeanswerp)
-#define _cleanup_asyncns_addrinfo_free_ _cleanup_(asyncns_freeaddrinfop)
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_asyncns_t*, sd_asyncns_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, sd_asyncns_freeanswer);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, sd_asyncns_freeaddrinfo);
+#define _cleanup_asyncns_free_ _cleanup_(sd_asyncns_freep)
+#define _cleanup_asyncns_answer_free_ _cleanup_(sd_asyncns_freeanswerp)
+#define _cleanup_asyncns_addrinfo_free_ _cleanup_(sd_asyncns_freeaddrinfop)
diff --git a/src/libsystemd-bus/sd-dns.c b/src/libsystemd-bus/sd-dns.c
index 0f90d02..7062ee2 100644
--- a/src/libsystemd-bus/sd-dns.c
+++ b/src/libsystemd-bus/sd-dns.c
@@ -68,27 +68,27 @@ enum {
 MESSAGE_FD_MAX = 4
 };
 
-struct asyncns {
+struct sd_asyncns {
 int fds[MESSAGE_FD_MAX];
 
 pthread_t workers[MAX_WORKERS];
 unsigned valid_workers;
 
 unsigned current_id, current_index;
-asyncns_query_t* queries[MAX_QUERIES];
+sd_asyncns_query_t* queries[MAX_QUERIES];
 
-asyncns_query_t *done_head, *done_tail;
+sd_asyncns_query_t *done_head, *done_tail;
 
 int n_queries;
 int dead;
 };
 
-struct asyncns_query {
-asyncns_t *asyncns;
+struct sd_asyncns_query {
+sd_asyncns_t *asyncns;
 int done;
 unsigned id;
 query_type_t type;
-asyncns_query_t *done_next, *done_prev;
+sd_asyncns_query_t *done_next, *done_prev;
 int ret;
 int _errno;
 int _h_errno;
@@ -383,7 +383,7 @@ static int handle_request(int out_fd, const packet_t 
*packet, size_t length) {
 }
 
 static void* thread_worker(void *p) {
-asyncns_t *asyncns = p;
+sd_asyncns_t *asyncns = p;
 sigset_t fullset;
 
 /* No signals in this thread please */
@@ -414,16 +414,16 @@ static void* thread_worker(void *p) {
 return NULL;
 }
 
-asyncns_t* asyncns_new(unsigned n_proc) {
+sd_asyncns_t* sd_asyncns_new(unsigned n_proc) {
 int i;
-asyncns_t *asyncns = NULL;
+sd_asyncns_t *asyncns = NULL;
 
 assert(n_proc = 1);
 
 if (n_proc  MAX_WORKERS)
 n_proc = MAX_WORKERS;
 
-asyncns = malloc(sizeof(asyncns_t));
+asyncns = malloc(sizeof(sd_asyncns_t));
 if (!asyncns) {
 errno = ENOMEM;
 goto fail;
@@ -475,12 +475,12 @@ asyncns_t* asyncns_new(unsigned n_proc) {
 
 fail:
 if (asyncns)
-asyncns_free(asyncns);
+sd_asyncns_free(asyncns);
 
 return NULL;
 }
 
-void asyncns_free(asyncns_t *asyncns) {
+void sd_asyncns_free(sd_asyncns_t *asyncns) {
 int i;
 int saved_errno = errno;
 unsigned p;
@@ -516,21 +516,21 @@ void asyncns_free(asyncns_t *asyncns) {
 
 for (p = 0; p  MAX_QUERIES; p++)
 if (asyncns-queries[p])
-asyncns_cancel(asyncns, asyncns-queries[p]);
+sd_asyncns_cancel(asyncns, asyncns-queries[p]);
 
 free(asyncns);
 
 errno = saved_errno;
 }
 
-int asyncns_fd(asyncns_t *asyncns) {
+int asyncns_fd(sd_asyncns_t *asyncns) {
 assert(asyncns);
 
 return asyncns-fds[RESPONSE_RECV_FD];
 }
 
-static asyncns_query_t *lookup_query(asyncns_t *asyncns, unsigned id) {
-asyncns_query_t *q;
+static sd_asyncns_query_t *lookup_query(sd_asyncns_t *asyncns, unsigned id) {
+sd_asyncns_query_t *q;
 assert(asyncns);
 
 q = asyncns-queries[id % MAX_QUERIES];
@@ -541,7 +541,7 @@ static asyncns_query_t *lookup_query(asyncns_t *asyncns, 
unsigned id) {
 return NULL;
 }
 
-static void complete_query(asyncns_t *asyncns, asyncns_query_t *q) {
+static void complete_query(sd_asyncns_t *asyncns, sd_asyncns_query_t *q) {
 assert(asyncns);
 assert(q);
 assert(!q-done);
@@ -608,14 +608,14 @@ static const void *unserialize_addrinfo(const void *p, 
struct addrinfo **ret_ai,
 
 fail:
 if (ai)
-asyncns_freeaddrinfo(ai);
+sd_asyncns_freeaddrinfo(ai);
 
 return NULL;
 }
 
-static int handle_response(asyncns_t *asyncns, const packet_t 

[systemd-devel] [PATCH 1/2] sd-dns: Codeing style cleanup

2014-01-12 Thread Daniel Buch
---
 src/libsystemd-bus/sd-dns.c   | 34 --
 src/libsystemd-bus/test-dns.c | 21 ++---
 2 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/src/libsystemd-bus/sd-dns.c b/src/libsystemd-bus/sd-dns.c
index 8126cb3..0f90d02 100644
--- a/src/libsystemd-bus/sd-dns.c
+++ b/src/libsystemd-bus/sd-dns.c
@@ -229,7 +229,8 @@ static int send_addrinfo_reply(int out_fd, unsigned id, int 
ret, struct addrinfo
 struct addrinfo *k;
 
 for (k = ai; k; k = k-ai_next) {
-if (!(p = serialize_addrinfo(p, k, 
resp-header.length, (char*) data + BUFSIZE - (char*) p))) {
+p = serialize_addrinfo(p, k, resp-header.length, 
(char*) data + BUFSIZE - (char*) p);
+if (!p) {
 resp-ret = EAI_MEMORY;
 break;
 }
@@ -457,8 +458,8 @@ asyncns_t* asyncns_new(unsigned n_proc) {
 
 for (asyncns-valid_workers = 0; asyncns-valid_workers  n_proc; 
asyncns-valid_workers++) {
 int r;
-
-if ((r = 
pthread_create(asyncns-workers[asyncns-valid_workers], NULL, thread_worker, 
asyncns)) != 0) {
+r = pthread_create(asyncns-workers[asyncns-valid_workers], 
NULL, thread_worker, asyncns);
+if (r) {
 errno = r;
 goto fail;
 }
@@ -532,7 +533,8 @@ static asyncns_query_t *lookup_query(asyncns_t *asyncns, 
unsigned id) {
 asyncns_query_t *q;
 assert(asyncns);
 
-if ((q = asyncns-queries[id % MAX_QUERIES]))
+q = asyncns-queries[id % MAX_QUERIES];
+if (q)
 if (q-id == id)
 return q;
 
@@ -572,7 +574,8 @@ static const void *unserialize_addrinfo(const void *p, 
struct addrinfo **ret_ai,
 if (*length  l)
 return NULL;
 
-if (!(ai = malloc(sizeof(struct addrinfo
+ai = malloc(sizeof(struct addrinfo));
+if (!ai)
 goto fail;
 
 ai-ai_addr = NULL;
@@ -626,7 +629,8 @@ static int handle_response(asyncns_t *asyncns, const 
packet_t *packet, size_t le
 return 0;
 }
 
-if (!(q = lookup_query(asyncns, resp-id)))
+q = lookup_query(asyncns, resp-id);
+if (!q)
 return 0;
 
 switch (resp-type) {
@@ -730,7 +734,8 @@ int asyncns_wait(asyncns_t *asyncns, int block) {
 return -1;
 }
 
-if (((l = recv(asyncns-fds[RESPONSE_RECV_FD], buf, 
sizeof(buf), 0))  0)) {
+l = recv(asyncns-fds[RESPONSE_RECV_FD], buf, sizeof(buf), 0);
+if (l  0) {
 fd_set fds;
 
 if (errno != EAGAIN)
@@ -765,7 +770,6 @@ static asyncns_query_t *alloc_query(asyncns_t *asyncns) {
 }
 
 while (asyncns-queries[asyncns-current_index]) {
-
 asyncns-current_index++;
 asyncns-current_id++;
 
@@ -773,7 +777,8 @@ static asyncns_query_t *alloc_query(asyncns_t *asyncns) {
 asyncns-current_index -= MAX_QUERIES;
 }
 
-if (!(q = asyncns-queries[asyncns-current_index] = 
malloc(sizeof(asyncns_query_t {
+q = asyncns-queries[asyncns-current_index] = 
malloc(sizeof(asyncns_query_t));
+if (!q) {
 errno = ENOMEM;
 return NULL;
 }
@@ -806,10 +811,10 @@ asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, 
const char *node, const
 return NULL;
 }
 
-if (!(q = alloc_query(asyncns)))
+q = alloc_query(asyncns);
+if (!q)
 return NULL;
 
-
 req-node_len = node ? strlen(node)+1 : 0;
 req-service_len = service ? strlen(service)+1 : 0;
 
@@ -892,10 +897,10 @@ asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, 
const struct sockaddr *
 return NULL;
 }
 
-if (!(q = alloc_query(asyncns)))
+q = alloc_query(asyncns);
+if (!q)
 return NULL;
 
-
 req-header.id = q-id;
 req-header.type = q-type = REQUEST_NAMEINFO;
 req-header.length = sizeof(nameinfo_request_t) + salen;
@@ -977,7 +982,8 @@ static asyncns_query_t * asyncns_res(asyncns_t *asyncns, 
query_type_t qtype, con
 return NULL;
 }
 
-if (!(q = alloc_query(asyncns)))
+q = alloc_query(asyncns);
+if (!q)
 return NULL;
 
 req-dname_len = strlen(dname) + 1;
diff --git a/src/libsystemd-bus/test-dns.c b/src/libsystemd-bus/test-dns.c
index 3e326ba..b4f064f 100644
--- a/src/libsystemd-bus/test-dns.c
+++ b/src/libsystemd-bus/test-dns.c
@@ -56,7 +56,6 @@ int main(int argc, char *argv[]) {
 hints.ai_socktype = SOCK_STREAM;
 
 q1 = asyncns_getaddrinfo(asyncns, argc = 2 ? 

[systemd-devel] [BUG] 8b255ecd99dfee

2014-01-11 Thread Daniel Buch
Hi,

bisect tells me this commit, 8b255ecd99dfee, causes gdm to crash when
--enable-kdbus is configured and the kdbus module isn't loaded.

Gdm starts but crashes and restarts as you enter your (correct)password.

Is this correct? Or am i missing something?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] initial sd-dns commit

2014-01-06 Thread Daniel Buch
Hi again,

Im hopeing we can continue in-tree since its easier from here, and im unable to 
get the time i want at the moment.
But i will ofcourse continue to help where i can when time permits.

I think the file nameing and locations are right?

Anyway heres what i got so far

---
 Makefile.am   |   29 +
 src/libsystemd-dns/asyncns-util.h |8 +
 src/libsystemd-dns/asyncns.c  | 1158 +
 src/libsystemd-dns/test-asyncns.c |  164 ++
 src/systemd/sd-dns.h  |  156 +
 5 files changed, 1515 insertions(+)
 create mode 100644 src/libsystemd-dns/asyncns-util.h
 create mode 100644 src/libsystemd-dns/asyncns.c
 create mode 100644 src/libsystemd-dns/test-asyncns.c
 create mode 100644 src/systemd/sd-dns.h

diff --git a/Makefile.am b/Makefile.am
index 069583c..9ae123a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -662,6 +662,35 @@ tests += \
 
 # 
--
 noinst_LTLIBRARIES += \
+   libsystemd-dns.la
+
+libsystemd_dns_la_SOURCES = \
+   src/systemd/sd-asyncns.h \
+   src/libsystemd-dns/asyncns.c \
+   src/libsystemd-dns/asyncns-util.h
+
+libsystemd_dns_la_LIBADD = \
+   libsystemd-shared.la
+
+libsystemd_dns_la_CFLAGS = \
+   -pthread
+
+test_dns_SOURCES = \
+   src/libsystemd-dns/test-asyncns.c \
+   src/systemd/sd-dns.h
+
+test_dns_LDADD = \
+   libsystemd-dns.la
+
+test_dns_LDFLAGS = \
+   -lresolv \
+   -pthread
+
+tests += \
+test-dns
+
+# 
--
+noinst_LTLIBRARIES += \
libsystemd-shared.la
 
 libsystemd_shared_la_SOURCES = \
diff --git a/src/libsystemd-dns/asyncns-util.h 
b/src/libsystemd-dns/asyncns-util.h
new file mode 100644
index 000..31d19bd
--- /dev/null
+++ b/src/libsystemd-dns/asyncns-util.h
@@ -0,0 +1,8 @@
+#pragma once
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(asyncns_t*, asyncns_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, asyncns_freeanswer);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, asyncns_freeaddrinfo);
+#define _cleanup_asyncns_free_ _cleanup_(asyncns_freep)
+#define _cleanup_asyncns_answer_free_ _cleanup_(asyncns_freeanswerp)
+#define _cleanup_asyncns_addrinfo_free_ _cleanup_(asyncns_freeaddrinfop)
diff --git a/src/libsystemd-dns/asyncns.c b/src/libsystemd-dns/asyncns.c
new file mode 100644
index 000..508f6b0
--- /dev/null
+++ b/src/libsystemd-dns/asyncns.c
@@ -0,0 +1,1158 @@
+/***
+  This file is part of libasyncns.
+
+  Copyright 2005-2008 Lennart Poettering
+
+  libasyncns is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation, either version 2.1 of the
+  License, or (at your option) any later version.
+
+  libasyncns is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with libasyncns. If not, see
+  http://www.gnu.org/licenses/.
+ ***/
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include assert.h
+#include fcntl.h
+#include signal.h
+#include unistd.h
+#include sys/select.h
+#include stdio.h
+#include string.h
+#include stdlib.h
+#include errno.h
+#include sys/wait.h
+#include sys/types.h
+#include pwd.h
+#include netinet/in.h
+#include arpa/nameser.h
+#include resolv.h
+#include dirent.h
+#include sys/time.h
+#include sys/resource.h
+#include stdint.h
+#include pthread.h
+
+#ifdef HAVE_SYS_PRCTL_H
+#include sys/prctl.h
+#endif
+
+#include sd-dns.h
+#include util.h
+
+#define MAX_WORKERS 16
+#define MAX_QUERIES 256
+#define BUFSIZE (10240)
+
+typedef enum {
+REQUEST_ADDRINFO,
+RESPONSE_ADDRINFO,
+REQUEST_NAMEINFO,
+RESPONSE_NAMEINFO,
+REQUEST_RES_QUERY,
+REQUEST_RES_SEARCH,
+RESPONSE_RES,
+REQUEST_TERMINATE,
+RESPONSE_DIED
+} query_type_t;
+
+enum {
+REQUEST_RECV_FD = 0,
+REQUEST_SEND_FD = 1,
+RESPONSE_RECV_FD = 2,
+RESPONSE_SEND_FD = 3,
+MESSAGE_FD_MAX = 4
+};
+
+struct asyncns {
+int fds[MESSAGE_FD_MAX];
+
+pthread_t workers[MAX_WORKERS];
+unsigned valid_workers;
+
+unsigned current_id, current_index;
+asyncns_query_t* queries[MAX_QUERIES];
+
+asyncns_query_t *done_head, *done_tail;
+
+int n_queries;
+int dead;
+};
+
+struct asyncns_query {
+asyncns_t *asyncns;
+int done;
+unsigned id;
+query_type_t type;
+asyncns_query_t *done_next, *done_prev;
+int ret;
+int _errno;
+int _h_errno;
+struct addrinfo *addrinfo;
+char *serv, *host;
+void *userdata;
+};
+

Re: [systemd-devel] [RFC] Initial libsystemd-asyncns commit

2014-01-03 Thread Daniel Buch
Yes im still working on it (Should have been finished days ago. 24 hours a
day is again not enough -.-). So far i went for the threaded version, and
cleaned up stuff according to this mail thread.

And i updated it to match systemd with c99 null initialisation of structs
etc. That might be wrong since you want it to be public now?


2014/1/3 David Timothy Strauss da...@davidstrauss.net

 Just to consider what other folks are doing, I know Fedora builds
 libcurl with a thread-isolated, NSS-based resolver.

 On a less-related note, at Pantheon improve DNS performance on servers
 by setting resolv.conf to localhost and running Unbound there. Unbound
 then uses the datacenter's recursive DNS servers for things that miss
 the local cache. This minimizes the time spent in blocked threads --
 and waiting for lookups even with async libraries. As a bonus, you
 also get DNSSec validation when possible.
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [RFC] Initial work for asyncns push

2013-12-10 Thread Daniel Buch
Hi,

So i layed the foundation of this libary to fit systemd

But what is actually desired?

C99 or C89? Do we want it to be public or private? Is modernization desired?

Daniel Buch (1):
  Initial libsystemd-asyncns commit

 Makefile.am   |   23 +
 src/libsystemd-asyncns/asyncns.c  | 1513 +
 src/libsystemd-asyncns/asyncns.h  |  163 
 src/libsystemd-asyncns/test-asyncns.c |  178 
 4 files changed, 1877 insertions(+)
 create mode 100644 src/libsystemd-asyncns/asyncns.c
 create mode 100644 src/libsystemd-asyncns/asyncns.h
 create mode 100644 src/libsystemd-asyncns/test-asyncns.c

-- 
1.8.5.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [RFC] Initial work for asyncns push

2013-12-10 Thread Daniel Buch
Cool, thanks you for the very decent reply.. I will work on this the next
few days, you can then expect some new RFC's :)


2013/12/11 Lennart Poettering lenn...@poettering.net

 On Wed, 11.12.13 02:18, Lennart Poettering (lenn...@poettering.net) wrote:

   C99 or C89? Do we want it to be public or private?
 
  Internally we use C99 and a lot of gcc extensions.
 
  Externally we limit ourselves to C89.
 
  One effect of this is that internally we use the C99 bool type for
  booleans, but externally we use int when things show up in public
  APIs.

 And to extend on this: this actually has weird effects. C99 bool will
 actually downgrade to int automatically when passed to functions as
 arguments (and vice versa). However gcc uses a different size in memory
 for this, which means that for doing call-by-value you can rely on this
 automatic conversion but if you do call-by-reference, then things will
 go boom in major ways.

 Lennart

 --
 Lennart Poettering, Red Hat

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] tree-wide usage of %m specifier instead of strerror(errno)

2013-11-26 Thread Daniel Buch
Also for log_error() except where a specific error is specified

e.g. errno ? strerror(errno) : Some user specified message
---
 TODO   |  2 --
 src/core/automount.c   |  2 +-
 src/core/main.c|  2 +-
 src/core/manager.c |  2 +-
 src/core/mount-setup.c |  2 +-
 src/core/service.c |  4 ++--
 src/initctl/initctl.c  | 12 +---
 src/journal/coredumpctl.c  |  2 +-
 src/journal/journald-console.c |  4 ++--
 src/journal/journald-kmsg.c|  2 +-
 src/udev/collect/collect.c |  6 +++---
 src/udev/scsi_id/scsi_id.c |  2 +-
 src/udev/scsi_id/scsi_serial.c |  8 +++-
 src/udev/udev-rules.c  |  2 +-
 14 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/TODO b/TODO
index d63e13e..653258a 100644
--- a/TODO
+++ b/TODO
@@ -824,8 +824,6 @@ Regularly:
 
 * Use PR_SET_PROCTITLE_AREA if it becomes available in the kernel
 
-* %m in printf() instead of strerror(errno);
-
 * pahole
 
 * set_put(), hashmap_put() return values check. i.e. == 0 doesn't free()!
diff --git a/src/core/automount.c b/src/core/automount.c
index 49a64b1..66e3d78 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -304,7 +304,7 @@ static int open_dev_autofs(Manager *m) {
 
 m-dev_autofs_fd = open(/dev/autofs, O_CLOEXEC|O_RDONLY);
 if (m-dev_autofs_fd  0) {
-log_error(Failed to open /dev/autofs: %s, strerror(errno));
+log_error(Failed to open /dev/autofs: %m);
 return -errno;
 }
 
diff --git a/src/core/main.c b/src/core/main.c
index dbc98db..69d3a43 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -131,7 +131,7 @@ _noreturn_ static void crash(int sig) {
 
 pid = fork();
 if (pid  0)
-log_error(Caught %s, cannot fork for core dump: 
%s, signal_to_string(sig), strerror(errno));
+log_error(Caught %s, cannot fork for core dump: 
%m, signal_to_string(sig));
 
 else if (pid == 0) {
 struct rlimit rl = {};
diff --git a/src/core/manager.c b/src/core/manager.c
index aa4baaa..65cb73c 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -307,7 +307,7 @@ static int enable_special_signals(Manager *m) {
 } else {
 /* Enable that we get SIGWINCH on kbrequest */
 if (ioctl(fd, KDSIGACCEPT, SIGWINCH)  0)
-log_warning(Failed to enable kbrequest handling: %s, 
strerror(errno));
+log_warning(Failed to enable kbrequest handling: %m);
 }
 
 return 0;
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index 73c2698..c601c97 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -188,7 +188,7 @@ static int mount_one(const MountPoint *p, bool relabel) {
   p-type,
   p-flags,
   p-options)  0) {
-log_full((p-mode  MNT_FATAL) ? LOG_ERR : LOG_DEBUG, Failed 
to mount %s: %s, p-where, strerror(errno));
+log_full((p-mode  MNT_FATAL) ? LOG_ERR : LOG_DEBUG, Failed 
to mount %s: %m, p-where);
 return (p-mode  MNT_FATAL) ? -errno : 0;
 }
 
diff --git a/src/core/service.c b/src/core/service.c
index 28b1465..7c5d5d8 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3507,7 +3507,7 @@ static int service_enumerate(Manager *m) {
 d = opendir(path);
 if (!d) {
 if (errno != ENOENT)
-log_warning(opendir(%s) failed: %s, 
path, strerror(errno));
+log_warning(opendir(%s) failed: %m, 
path);
 
 continue;
 }
@@ -3540,7 +3540,7 @@ static int service_enumerate(Manager *m) {
 if (access(fpath, X_OK)  0) {
 
 if (errno != ENOENT)
-log_warning(access() failed 
on %s: %s, fpath, strerror(errno));
+log_warning(access() failed 
on %s: %m, fpath);
 
 continue;
 }
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index d6c..284319f 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -217,7 +217,7 @@ static int fifo_process(Fifo *f) {
 if (errno == EAGAIN)
 return 0;
 
-log_warning(Failed to read from fifo: %s, strerror(errno));
+log_warning(Failed to read from fifo: %m);
 return -1;
 }
 
@@ -278,7 +278,7 @@ static int server_init(Server *s, unsigned n_sockets) {
 s-epoll_fd = epoll_create1(EPOLL_CLOEXEC);
 if (s-epoll_fd  0) {
 r = 

Re: [systemd-devel] test-strv.c

2013-11-06 Thread Daniel Buch
Thank you Zbyszek. The indent mess i did, Lennart cleaned it up here :)

http://cgit.freedesktop.org/systemd/systemd/commit/?id=250a918dc4c8a15d927deecc3b3f6a0604657ae4

(So much for cleaning up vimrc, and leave out shiftwidth+friends out..
Anyway fixed)




2013/11/7 Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl

 On Thu, Oct 31, 2013 at 10:03:07AM +0100, Daniel Buch wrote:
  Hi there,
 
  By these 3 patches test_strv.c should be complete
 Applied as one patch.

  Sorry for the tap mess i pushed, wont happen again ;)
 Mess, what mess? :)

 Zbyszek


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/3] test-strv.c: added strv_split

2013-10-31 Thread Daniel Buch
---
 src/test/test-strv.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index f32d02e..e96200e 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -156,6 +156,21 @@ static void test_strv_quote_unquote(const char* const 
*split, const char *quoted
 }
 }
 
+static void test_strv_split(void) {
+char **s;
+unsigned i = 0;
+_cleanup_strv_free_ char **l = NULL;
+const char str[] = one,two,three;
+
+l = strv_split(str, ,);
+
+assert(l);
+
+STRV_FOREACH(s, l) {
+assert_se(streq(*s, input_table_multiple[i++]));
+}
+}
+
 static void test_strv_split_nulstr(void) {
 _cleanup_strv_free_ char **l = NULL;
 const char nulstr[] = str0\0str1\0str2\0str3\0;
@@ -359,6 +374,7 @@ int main(int argc, char *argv[]) {
 test_strv_quote_unquote(input_table_quotes, QUOTES_STRING);
 test_strv_quote_unquote(input_table_spaces, SPACES_STRING);
 
+test_strv_split();
 test_strv_split_nulstr();
 test_strv_parse_nulstr();
 test_strv_overlap();
-- 
1.8.4.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/3] test-strv.c: added strv_split_newline

2013-10-31 Thread Daniel Buch
---
 src/test/test-strv.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index e96200e..9b51d82 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -171,6 +171,21 @@ static void test_strv_split(void) {
 }
 }
 
+static void test_strv_split_newlines(void) {
+unsigned i = 0;
+char **s;
+_cleanup_strv_free_ char **l = NULL;
+const char str[] = one\ntwo\nthree;
+
+l = strv_split_newlines(str);
+
+assert(l);
+
+STRV_FOREACH(s, l) {
+assert_se(streq(*s, input_table_multiple[i++]));
+}
+}
+
 static void test_strv_split_nulstr(void) {
 _cleanup_strv_free_ char **l = NULL;
 const char nulstr[] = str0\0str1\0str2\0str3\0;
@@ -375,6 +390,7 @@ int main(int argc, char *argv[]) {
 test_strv_quote_unquote(input_table_spaces, SPACES_STRING);
 
 test_strv_split();
+test_strv_split_newlines();
 test_strv_split_nulstr();
 test_strv_parse_nulstr();
 test_strv_overlap();
-- 
1.8.4.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 3/3] test-strv.c: added test_strv_remove_prefix

2013-10-31 Thread Daniel Buch
---
 src/test/test-strv.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 9b51d82..e468859 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -199,6 +199,22 @@ static void test_strv_split_nulstr(void) {
 assert_se(streq(l[3], str3));
 }
 
+static void test_strv_remove_prefix(void) {
+unsigned i = 0;
+char **s;
+_cleanup_strv_free_ char **l = NULL;
+
+l = strv_new(_one, _two, _three, NULL);
+assert(l);
+
+l = strv_remove_prefix(l, _);
+assert(l);
+
+STRV_FOREACH(s, l) {
+assert_se(streq(*s, input_table_multiple[i++]));
+}
+}
+
 static void test_strv_parse_nulstr(void) {
 _cleanup_strv_free_ char **l = NULL;
 const char nulstr[] = fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx;
@@ -393,6 +409,7 @@ int main(int argc, char *argv[]) {
 test_strv_split_newlines();
 test_strv_split_nulstr();
 test_strv_parse_nulstr();
+test_strv_remove_prefix();
 test_strv_overlap();
 test_strv_sort();
 test_strv_merge();
-- 
1.8.4.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] test-strv.c

2013-10-31 Thread Daniel Buch
Hi there,

By these 3 patches test_strv.c should be complete

Sorry for the tap mess i pushed, wont happen again ;)

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/2] path_lookup: moved _cleanup_lookup_paths_free_ from install.c to path-lookup.h

2013-10-27 Thread Daniel Buch
---
 src/shared/install.c  | 1 -
 src/shared/path-lookup.h  | 2 ++
 src/systemctl/systemctl.c | 4 +---
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 3bced1a..987b36d 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -44,7 +44,6 @@ typedef struct {
 Hashmap *have_installed;
 } InstallContext;
 
-#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
 #define _cleanup_install_context_done_ _cleanup_(install_context_done)
 
 static int lookup_paths_init_from_scope(LookupPaths *paths, UnitFileScope 
scope) {
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index 9dee85f..a3ef824 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -36,6 +36,8 @@ typedef enum SystemdRunningAs {
 _SYSTEMD_RUNNING_AS_INVALID = -1
 } SystemdRunningAs;
 
+#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
+
 const char* systemd_running_as_to_string(SystemdRunningAs i) _const_;
 SystemdRunningAs systemd_running_as_from_string(const char *s) _pure_;
 
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index d458c65..87a6985 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4223,7 +4223,7 @@ static int enable_sysv_units(const char *verb, char 
**args) {
 
 #if defined(HAVE_SYSV_COMPAT)  defined(HAVE_CHKCONFIG)
 unsigned f = 1, t = 1;
-LookupPaths paths = {};
+_cleanup_lookup_paths_free_ LookupPaths paths = {};
 
 if (arg_scope != UNIT_FILE_SYSTEM)
 return 0;
@@ -4361,8 +4361,6 @@ static int enable_sysv_units(const char *verb, char 
**args) {
 }
 
 finish:
-lookup_paths_free(paths);
-
 /* Drop all SysV units */
 for (f = 0, t = 0; args[f]; f++) {
 
-- 
1.8.4.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/2] test-strv.c: added STRV_FOREACH and STRV_FOREACH_BACKWARDS

2013-10-27 Thread Daniel Buch
---
 src/test/test-strv.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index c3d536d..de5cef0 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -282,6 +282,34 @@ static void test_strv_append(void) {
 assert_se(streq(c[0], test3));
 }
 
+static void test_strv_foreach(void) {
+   _cleanup_strv_free_ char **a;
+   unsigned i = 0;
+   char **check;
+
+   a = strv_new(one, two, three, NULL);
+
+   assert_se(a);
+
+   STRV_FOREACH(check, a) {
+   assert_se(streq(*check, input_table_multiple[i++]));
+   }
+}
+
+static void test_strv_foreach_backwards(void) {
+   _cleanup_strv_free_ char **a;
+   unsigned i = 2;
+   char **check;
+
+   a = strv_new(one, two, three, NULL);
+
+   assert_se(a);
+
+   STRV_FOREACH_BACKWARDS(check, a) {
+   assert_se(streq(*check, input_table_multiple[i--]));
+   }
+}
+
 static void test_strv_foreach_pair(void) {
 _cleanup_strv_free_ char **a = NULL;
 char **x, **y;
@@ -298,6 +326,8 @@ static void test_strv_foreach_pair(void) {
 
 int main(int argc, char *argv[]) {
 test_specifier_printf();
+test_strv_foreach();
+test_strv_foreach_backwards();
 test_strv_foreach_pair();
 test_strv_find();
 test_strv_find_prefix();
-- 
1.8.4.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] test-hashmap.c: added unit-test for hashmap

2013-05-02 Thread Daniel Buch
Thanks for review, kay!

I adabted the code. So trivial_cmp() is tested with INT_TO_PTR('a') - i
guess its ok to use 'a' since its evaulated to int?
The casts.. Dont know :p they are removed :)


2013/4/26 Kay Sievers k...@vrfy.org

 On Fri, Apr 26, 2013 at 8:49 PM, Daniel Buch boogiewasth...@gmail.com
 wrote:
  Version 2, with leak fix. This should be good enough to be pushed.

  +static void test_uint64_compare_func(void) {
  +assert_se((uint64_t)trivial_compare_func(a, a) ==
 (uint64_t)0);
  +assert_se((uint64_t)trivial_compare_func(a, b) ==
 (uint64_t)-1);
  +assert_se((uint64_t)trivial_compare_func(b, a) ==
 (uint64_t)1);
  +}
  +
  +static void test_trivial_compare_func(void) {
  +assert_se(trivial_compare_func(a, a) == 0);
  +assert_se(trivial_compare_func(a, b) == -1);
  +assert_se(trivial_compare_func(b, a) == 1);
  +}

 We cannot use trivial here to compare string values and expect
 predictable results. Trivial will just compare the raw pointers,
 which the compiler can arrange as it likes to; a is not necessarily
 the same as another a. No doubt, the hashmap.c code should get some
 comments here explaining things and how they can/should be used, it's
 really not obvious what's going on.

 We can only compare numeric values with INT_TO_PTR(333) or something like
 that.

 What is the  (uint64_t) cast supposed to test here? And we cast a -1
 to an unsigned? That's intentional?

 Thanks,
 Kay

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] test-hashmap.c: added unit-test for hashmap

2013-05-02 Thread Daniel Buch
Updated version

---
 Makefile.am |  12 +-
 src/test/test-hashmap.c | 508 
 2 files changed, 519 insertions(+), 1 deletion(-)
 create mode 100644 src/test/test-hashmap.c

diff --git a/Makefile.am b/Makefile.am
index 9e0f5fb..d50ab3d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1102,7 +1102,8 @@ tests += \
test-cgroup-util \
test-prioq \
test-fileio \
-   test-time
+   test-time \
+   test-hashmap
 
 EXTRA_DIST += \
test/sched_idle_bad.service \
@@ -1193,6 +1194,15 @@ test_util_CFLAGS = \
 test_util_LDADD = \
libsystemd-core.la
 
+test_hashmap_SOURCES = \
+   src/test/test-hashmap.c
+
+test_hashmap_CFLAGS = \
+   $(AM_CFLAGS)
+
+test_hashmap_LDADD = \
+   libsystemd-core.la
+
 test_prioq_SOURCES = \
src/test/test-prioq.c
 
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
new file mode 100644
index 000..2aead79
--- /dev/null
+++ b/src/test/test-hashmap.c
@@ -0,0 +1,508 @@
+/***
+  This file is part of systemd
+
+  Copyright 2013 Daniel Buch
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see http://www.gnu.org/licenses/.
+***/
+
+#include inttypes.h
+#include strv.h
+#include util.h
+#include hashmap.h
+
+static void test_hashmap_replace(void) {
+Hashmap *m;
+char *val1, *val2, *val3, *val4, *val5, *r;
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+val5 = strdup(val5);
+assert_se(val5);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+hashmap_replace(m, key 3, val1);
+r = hashmap_get(m, key 3);
+assert_se(streq(r, val1));
+
+hashmap_replace(m, key 5, val5);
+r = hashmap_get(m, key 5);
+assert_se(streq(r, val5));
+
+free(val1);
+free(val2);
+free(val3);
+free(val4);
+free(val5);
+hashmap_free(m);
+}
+
+static void test_hashmap_copy(void) {
+Hashmap *m, *copy;
+char *val1, *val2, *val3, *val4, *r;
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+copy = hashmap_copy(m);
+
+r = hashmap_get(copy, key 1);
+assert_se(streq(r, val1));
+r = hashmap_get(copy, key 2);
+assert_se(streq(r, val2));
+r = hashmap_get(copy, key 3);
+assert_se(streq(r, val3));
+r = hashmap_get(copy, key 4);
+assert_se(streq(r, val4));
+
+hashmap_free_free(copy);
+hashmap_free(m);
+}
+
+static void test_hashmap_get_strv(void) {
+Hashmap *m;
+char **strv;
+char *val1, *val2, *val3, *val4;
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+strv = hashmap_get_strv(m);
+
+assert_se(streq(strv[0], val1));
+assert_se(streq(strv[1], val2));
+assert_se(streq(strv[2], val3));
+assert_se(streq(strv[3], val4));
+
+strv_free(strv);
+
+hashmap_free(m);
+}
+
+static void test_hashmap_move_one(void) {
+Hashmap *m, *n;
+char *val1, *val2, *val3, *val4, *r;
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+
+m

[systemd-devel] [PATCH 1/2] test-hashmap.c first part

2013-04-26 Thread Daniel Buch
Hi,

So this is comming along, and i want to finish this soon but i got a question;

* What are do you think about using strv_new() + friends for allocateing 
hashmap values/keys insted of strdup()'s ?


---
 Makefile.am |  12 +-
 src/test/test-hashmap.c | 506 
 2 files changed, 517 insertions(+), 1 deletion(-)
 create mode 100644 src/test/test-hashmap.c

diff --git a/Makefile.am b/Makefile.am
index ff70223..44ee052 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1100,7 +1100,8 @@ tests += \
test-cgroup-util \
test-prioq \
test-fileio \
-   test-time
+   test-time \
+   test-hashmap
 
 EXTRA_DIST += \
test/sched_idle_bad.service \
@@ -1191,6 +1192,15 @@ test_util_CFLAGS = \
 test_util_LDADD = \
libsystemd-core.la
 
+test_hashmap_SOURCES = \
+   src/test/test-hashmap.c
+
+test_hashmap_CFLAGS = \
+   $(AM_CFLAGS)
+
+test_hashmap_LDADD = \
+   libsystemd-core.la
+
 test_prioq_SOURCES = \
src/test/test-prioq.c
 
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
new file mode 100644
index 000..9b94986
--- /dev/null
+++ b/src/test/test-hashmap.c
@@ -0,0 +1,506 @@
+/***
+  This file is part of systemd
+
+  Copyright 2013 Daniel Buch
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see http://www.gnu.org/licenses/.
+***/
+
+#include inttypes.h
+#include strv.h
+#include util.h
+#include hashmap.h
+
+static void test_hashmap_replace(void) {
+Hashmap *m;
+char *val1, *val2, *val3, *val4, *val5, *r;
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+val5 = strdup(val5);
+assert_se(val5);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+hashmap_replace(m, key 3, val1);
+r = hashmap_get(m, key 3);
+assert_se(streq(r, val1));
+
+hashmap_replace(m, key 5, val5);
+r = hashmap_get(m, key 5);
+assert_se(streq(r, val5));
+
+free(val1);
+free(val2);
+free(val3);
+free(val4);
+free(val5);
+hashmap_free(m);
+}
+
+static void test_hashmap_copy(void) {
+Hashmap *m, *copy;
+char *val1, *val2, *val3, *val4, *r;
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+copy = hashmap_copy(m);
+
+r = hashmap_get(copy, key 1);
+assert_se(streq(r, val1));
+r = hashmap_get(copy, key 2);
+assert_se(streq(r, val2));
+r = hashmap_get(copy, key 3);
+assert_se(streq(r, val3));
+r = hashmap_get(copy, key 4);
+assert_se(streq(r, val4));
+
+hashmap_free(copy);
+hashmap_free_free(m);
+}
+
+static void test_hashmap_get_strv(void) {
+Hashmap *m;
+char **strv;
+char *val1, *val2, *val3, *val4;
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+strv = hashmap_get_strv(m);
+
+assert_se(streq(strv[0], val1));
+assert_se(streq(strv[1], val2));
+assert_se(streq(strv[2], val3));
+assert_se(streq(strv[3], val4));
+
+strv_free(strv);
+
+hashmap_free(m);
+}
+
+static void test_hashmap_move_one(void) {
+Hashmap *m, *n;
+char *val1, *val2, *val3, *val4, *r;
+
+val1 = strdup(val1);
+assert_se(val1

[systemd-devel] [PATCH 2/2] hashmap.h: fix coding style issue

2013-04-26 Thread Daniel Buch
---
 src/shared/hashmap.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/shared/hashmap.h b/src/shared/hashmap.h
index 26bd030..f52517f 100644
--- a/src/shared/hashmap.h
+++ b/src/shared/hashmap.h
@@ -57,11 +57,11 @@ int hashmap_ensure_allocated(Hashmap **h, hash_func_t 
hash_func, compare_func_t
 int hashmap_put(Hashmap *h, const void *key, void *value);
 int hashmap_update(Hashmap *h, const void *key, void *value);
 int hashmap_replace(Hashmap *h, const void *key, void *value);
-void* hashmap_get(Hashmap *h, const void *key);
-void* hashmap_get2(Hashmap *h, const void *key, void **rkey);
+void *hashmap_get(Hashmap *h, const void *key);
+void *hashmap_get2(Hashmap *h, const void *key, void **rkey);
 bool hashmap_contains(Hashmap *h, const void *key);
-void* hashmap_remove(Hashmap *h, const void *key);
-void* hashmap_remove_value(Hashmap *h, const void *key, void *value);
+void *hashmap_remove(Hashmap *h, const void *key);
+void *hashmap_remove_value(Hashmap *h, const void *key, void *value);
 int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void 
*new_key, void *value);
 int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void 
*new_key, void *value);
 
@@ -82,9 +82,9 @@ void hashmap_clear_free_free(Hashmap *h);
 
 void *hashmap_steal_first(Hashmap *h);
 void *hashmap_steal_first_key(Hashmap *h);
-void* hashmap_first(Hashmap *h);
-void* hashmap_first_key(Hashmap *h);
-void* hashmap_last(Hashmap *h);
+void *hashmap_first(Hashmap *h);
+void *hashmap_first_key(Hashmap *h);
+void *hashmap_last(Hashmap *h);
 
 void *hashmap_next(Hashmap *h, const void *key);
 
-- 
1.8.2.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/2] hashmap.h: fix coding style issue

2013-04-26 Thread Daniel Buch
I felt the inconsistentsy was kinda awfull.

I can change all to void* (instead of, void *) if you like but else leave
this patch to the trash?


2013/4/26 Kay Sievers k...@vrfy.org

 On Fri, Apr 26, 2013 at 7:49 PM, Zbigniew Jędrzejewski-Szmek
 zbys...@in.waw.pl wrote:
  On Fri, Apr 26, 2013 at 06:40:08PM +0200, Daniel Buch wrote:
  ---
   src/shared/hashmap.h | 14 +++---
   1 file changed, 7 insertions(+), 7 deletions(-)
 
  diff --git a/src/shared/hashmap.h b/src/shared/hashmap.h
  index 26bd030..f52517f 100644
  --- a/src/shared/hashmap.h
  +++ b/src/shared/hashmap.h
  @@ -57,11 +57,11 @@ int hashmap_ensure_allocated(Hashmap **h,
 hash_func_t hash_func, compare_func_t
   int hashmap_put(Hashmap *h, const void *key, void *value);
   int hashmap_update(Hashmap *h, const void *key, void *value);
   int hashmap_replace(Hashmap *h, const void *key, void *value);
  -void* hashmap_get(Hashmap *h, const void *key);
  -void* hashmap_get2(Hashmap *h, const void *key, void **rkey);
  +void *hashmap_get(Hashmap *h, const void *key);
  +void *hashmap_get2(Hashmap *h, const void *key, void **rkey);
   bool hashmap_contains(Hashmap *h, const void *key);
  -void* hashmap_remove(Hashmap *h, const void *key);
  -void* hashmap_remove_value(Hashmap *h, const void *key, void *value);
  +void *hashmap_remove(Hashmap *h, const void *key);
  +void *hashmap_remove_value(Hashmap *h, const void *key, void *value);
   int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void
 *new_key, void *value);
 
  I find the updated version actually harder to read. We seem to
 consistently
  use 'char* xxx()', and 'void* xxx' is more common than 'void *xxx'.

 What's the point of the inconsistent:
   void* hashmap_get(Hashmap *h, const void *key)

 it needs to be:
   void* hashmap_get(Hashmap* h, const void* key)

 then, if we really go there. :)

 Kay

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] test-hashmap.c: added unit-test for hashmap

2013-04-26 Thread Daniel Buch
Version 2, with leak fix. This should be good enough to be pushed.

---
 Makefile.am |  12 +-
 src/test/test-hashmap.c | 508 
 2 files changed, 519 insertions(+), 1 deletion(-)
 create mode 100644 src/test/test-hashmap.c

diff --git a/Makefile.am b/Makefile.am
index ff70223..44ee052 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1100,7 +1100,8 @@ tests += \
test-cgroup-util \
test-prioq \
test-fileio \
-   test-time
+   test-time \
+   test-hashmap
 
 EXTRA_DIST += \
test/sched_idle_bad.service \
@@ -1191,6 +1192,15 @@ test_util_CFLAGS = \
 test_util_LDADD = \
libsystemd-core.la
 
+test_hashmap_SOURCES = \
+   src/test/test-hashmap.c
+
+test_hashmap_CFLAGS = \
+   $(AM_CFLAGS)
+
+test_hashmap_LDADD = \
+   libsystemd-core.la
+
 test_prioq_SOURCES = \
src/test/test-prioq.c
 
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
new file mode 100644
index 000..7c55c87
--- /dev/null
+++ b/src/test/test-hashmap.c
@@ -0,0 +1,508 @@
+/***
+  This file is part of systemd
+
+  Copyright 2013 Daniel Buch
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see http://www.gnu.org/licenses/.
+***/
+
+#include inttypes.h
+#include strv.h
+#include util.h
+#include hashmap.h
+
+static void test_hashmap_replace(void) {
+Hashmap *m;
+char *val1, *val2, *val3, *val4, *val5, *r;
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+val5 = strdup(val5);
+assert_se(val5);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+hashmap_replace(m, key 3, val1);
+r = hashmap_get(m, key 3);
+assert_se(streq(r, val1));
+
+hashmap_replace(m, key 5, val5);
+r = hashmap_get(m, key 5);
+assert_se(streq(r, val5));
+
+free(val1);
+free(val2);
+free(val3);
+free(val4);
+free(val5);
+hashmap_free(m);
+}
+
+static void test_hashmap_copy(void) {
+Hashmap *m, *copy;
+char *val1, *val2, *val3, *val4, *r;
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+copy = hashmap_copy(m);
+
+r = hashmap_get(copy, key 1);
+assert_se(streq(r, val1));
+r = hashmap_get(copy, key 2);
+assert_se(streq(r, val2));
+r = hashmap_get(copy, key 3);
+assert_se(streq(r, val3));
+r = hashmap_get(copy, key 4);
+assert_se(streq(r, val4));
+
+hashmap_free_free(copy);
+hashmap_free(m);
+}
+
+static void test_hashmap_get_strv(void) {
+Hashmap *m;
+char **strv;
+char *val1, *val2, *val3, *val4;
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup(val4);
+assert_se(val4);
+
+m = hashmap_new(string_hash_func, string_compare_func);
+
+hashmap_put(m, key 1, val1);
+hashmap_put(m, key 2, val2);
+hashmap_put(m, key 3, val3);
+hashmap_put(m, key 4, val4);
+
+strv = hashmap_get_strv(m);
+
+assert_se(streq(strv[0], val1));
+assert_se(streq(strv[1], val2));
+assert_se(streq(strv[2], val3));
+assert_se(streq(strv[3], val4));
+
+strv_free(strv);
+
+hashmap_free(m);
+}
+
+static void test_hashmap_move_one(void) {
+Hashmap *m, *n;
+char *val1, *val2, *val3, *val4, *r;
+
+val1 = strdup(val1);
+assert_se(val1);
+val2 = strdup(val2);
+assert_se(val2);
+val3 = strdup(val3);
+assert_se(val3);
+val4 = strdup

[systemd-devel] [PATCH] test-hashmap.c first part

2013-03-26 Thread Daniel Buch
This is first part of hashmap test unit - last part is in development. So 
review is much appreciated

Thanks in advance.

---
 Makefile.am |  10 +++
 src/test/test-hashmap.c | 203 
 2 files changed, 213 insertions(+)
 create mode 100644 src/test/test-hashmap.c

diff --git a/Makefile.am b/Makefile.am
index d5eb7ad..a95dd6e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1075,6 +1075,7 @@ noinst_tests += \
test-unit-name \
test-unit-file \
test-util \
+   test-hashmap \
test-date \
test-sleep \
test-replace-var \
@@ -1182,6 +1183,15 @@ test_prioq_CFLAGS = \
 test_prioq_LDADD = \
libsystemd-core.la
 
+test_hashmap_SOURCES = \
+   src/test/test-hashmap.c
+
+test_hashmap_CFLAGS = \
+   $(AM_CFLAGS)
+
+test_hashmap_LDADD = \
+   libsystemd-core.la
+
 test_log_SOURCES = \
src/test/test-log.c
 
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
new file mode 100644
index 000..610607b
--- /dev/null
+++ b/src/test/test-hashmap.c
@@ -0,0 +1,203 @@
+#include inttypes.h
+#include util.h
+#include hashmap.h
+
+#define FOREACH_CONST_CHAR(value, table) \
+for (const char **(value) = (table); (value)  *(value); (value)++)
+
+static void test_hashmap_foreach_key(void) {
+Hashmap *m = hashmap_new(string_hash_func, string_compare_func);
+Iterator i;
+const char *s;
+const char *key_table[] = {key 1, key 2, key 3, key 4, NULL };
+bool key_found[] = { false, false, false, false };
+
+FOREACH_CONST_CHAR(value, key_table)
+hashmap_put(m, *value, (void*) (const char*) blah);
+
+HASHMAP_FOREACH_KEY(s, key_table, m, i) {
+if (!key_found[0]  streq(*key_table, key 1))
+key_found[0] = true;
+else if (!key_found[1]  streq(*key_table, key 2))
+key_found[1] = true;
+else if (!key_found[2]  streq(*key_table, key 3))
+key_found[2] = true;
+else if (!key_found[3]  streq(*key_table, fail))
+key_found[3] = true;
+}
+
+assert_se(key_found[0]  key_found[1]  key_found[2]  
!key_found[3]);
+
+hashmap_free(m);
+}
+
+static void test_hashmap_foreach(void) {
+Hashmap *m = hashmap_new(string_hash_func, string_compare_func);
+Iterator i;
+char *s;
+char *val1 = strdup(my val1);
+char *val2 = strdup(my val2);
+char *val3 = strdup(my val3);
+char *val4 = strdup(my val4);
+bool value_found[] = { false, false, false, false };
+
+hashmap_put(m, KeyN 1, val1);
+hashmap_put(m, KeyN 2, val2);
+hashmap_put(m, KeyN 3, val3);
+hashmap_put(m, KeyN 4, val4);
+
+HASHMAP_FOREACH(s, m, i) {
+if (!value_found[0]  streq(s, val1))
+value_found[0] = true;
+else if (!value_found[1]  streq(s, val2))
+value_found[1] = true;
+else if (!value_found[2]  streq(s, val3))
+value_found[2] = true;
+else if (!value_found[3]  streq(s, val4))
+value_found[3] = true;
+}
+
+assert_se(value_found[0]  value_found[1]  value_found[2]  
value_found[3]);
+
+hashmap_free_free(m);
+}
+
+static void test_hashmap_foreach_backwards(void) {
+Hashmap *m = hashmap_new(string_hash_func, string_compare_func);
+Iterator i;
+char *s;
+char *val1 = strdup(my val1);
+char *val2 = strdup(my val2);
+char *val3 = strdup(my val3);
+char *val4 = strdup(my val4);
+bool value_found[] = { false, false, false, false };
+
+hashmap_put(m, KeyN 1, val1);
+hashmap_put(m, KeyN 2, val2);
+hashmap_put(m, KeyN 3, val3);
+hashmap_put(m, KeyN 4, val4);
+
+HASHMAP_FOREACH_BACKWARDS(s, m, i) {
+if (!value_found[0]  streq(s, val1))
+value_found[0] = true;
+else if (!value_found[1]  streq(s, val2))
+value_found[1] = true;
+else if (!value_found[2]  streq(s, val3))
+value_found[2] = true;
+else if (!value_found[3]  streq(s, val4))
+value_found[3] = true;
+}
+
+assert_se(value_found[0]  value_found[1]  value_found[2]  
value_found[3]);
+
+hashmap_free_free(m);
+}
+
+static void test_hashmap_merge(void) {
+Hashmap *m = hashmap_new(string_hash_func, string_compare_func);
+Hashmap *n = hashmap_new(string_hash_func, string_compare_func);
+
+char *val1 = strdup(my val1);
+char *val2 = strdup(my val2);
+char *val3 = strdup(my val3);
+char *val4 = strdup(my val4);
+
+hashmap_put(m, KeyN 1, val1);
+

[systemd-devel] [PATCH] test-strv.c: added OOM check for current tests

2013-02-18 Thread Daniel Buch
New OOM check patch:

I do assert_se() before variable is used to do correct check.

---
 src/test/test-strv.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index d2eb225..504415a 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -87,18 +87,23 @@ static void test_strv_join(void) {
 };
 
 p = strv_join((char **)input_table_multiple, , );
+assert_se(p);
 assert_se(streq(p, one, two, three));
 
 q = strv_join((char **)input_table_multiple, ;);
+assert_se(q);
 assert_se(streq(q, one;two;three));
 
 r = strv_join((char **)input_table_multiple, NULL);
+assert_se(r);
 assert_se(streq(r, one two three));
 
 s = strv_join((char **)input_table_one, , );
+assert_se(s);
 assert_se(streq(s, one));
 
 t = strv_join((char **)input_table_none, , );
+assert_se(t);
 assert_se(streq(t, ));
 }
 
@@ -107,6 +112,7 @@ static void test_strv_split_nulstr(void) {
 const char nulstr[] = str0\0str1\0str2\0str3\0;
 
 l = strv_split_nulstr (nulstr);
+assert_se(l);
 
 assert_se(streq(l[0], str0));
 assert_se(streq(l[1], str1));
@@ -119,6 +125,7 @@ static void test_strv_parse_nulstr(void) {
 const char nulstr[] = fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx;
 
 l = strv_parse_nulstr(nulstr, sizeof(nulstr)-1);
+assert_se(l);
 puts(Parse nulstr:);
 strv_print(l);
 
@@ -177,8 +184,11 @@ static void test_strv_merge_concat(void) {
 
 a = strv_new(without, suffix, NULL);
 b = strv_new(with, suffix, NULL);
+assert_se(a);
+assert_se(b);
 
 c = strv_merge_concat(a, b, _suffix);
+assert_se(c);
 
 assert_se(streq(c[0], without));
 assert_se(streq(c[1], suffix));
@@ -191,8 +201,11 @@ static void test_strv_merge(void) {
 
 a = strv_new(abc, def, ghi, NULL);
 b = strv_new(jkl, mno, pqr, NULL);
+assert_se(a);
+assert_se(b);
 
 c = strv_merge(a, b);
+assert_se(c);
 
 assert_se(streq(c[0], abc));
 assert_se(streq(c[1], def));
@@ -208,8 +221,11 @@ static void test_strv_append(void) {
 _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL;
 
 a = strv_new(test, test1, NULL);
+assert_se(a);
 b = strv_append(a, test2);
 c = strv_append(NULL, test3);
+assert_se(b);
+assert_se(c);
 
 assert_se(streq(b[0], test));
 assert_se(streq(b[1], test1));
-- 
1.8.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/3] test-strv.c: added strv_split_nulstr() test

2013-02-17 Thread Daniel Buch
---
 src/test/test-strv.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index a8801b5..ea1f088 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -100,6 +100,18 @@ static void test_strv_join(void) {
 assert_se(streq(t, ));
 }
 
+static void test_strv_split_nulstr(void) {
+_cleanup_strv_free_ char **l = NULL;
+const char nulstr[] = str0\0str1\0str2\0str3\0;
+
+l = strv_split_nulstr (nulstr);
+
+assert_se(streq(l[0], str0));
+assert_se(streq(l[1], str1));
+assert_se(streq(l[2], str2));
+assert_se(streq(l[3], str3));
+}
+
 static void test_strv_parse_nulstr(void) {
 _cleanup_strv_free_ char **l = NULL;
 const char nulstr[] = fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx;
@@ -208,6 +220,7 @@ int main(int argc, char *argv[]) {
 test_strv_find();
 test_strv_find_prefix();
 test_strv_join();
+test_strv_split_nulstr();
 test_strv_parse_nulstr();
 test_strv_overlap();
 test_strv_sort();
-- 
1.8.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/3] test-strv.c: added OOM check for current tests

2013-02-17 Thread Daniel Buch
---
 src/test/test-strv.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index ea1f088..e33568c 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -85,18 +85,23 @@ static void test_strv_join(void) {
 };
 
 p = strv_join((char **)input_table_multiple, , );
+assert_se(p);
 assert_se(streq(p, one, two, three));
 
 q = strv_join((char **)input_table_multiple, ;);
+assert_se(q);
 assert_se(streq(q, one;two;three));
 
 r = strv_join((char **)input_table_multiple, NULL);
+assert_se(r);
 assert_se(streq(r, one two three));
 
 s = strv_join((char **)input_table_one, , );
+assert_se(s);
 assert_se(streq(s, one));
 
 t = strv_join((char **)input_table_none, , );
+assert_se(t);
 assert_se(streq(t, ));
 }
 
@@ -106,6 +111,8 @@ static void test_strv_split_nulstr(void) {
 
 l = strv_split_nulstr (nulstr);
 
+assert_se(l);
+
 assert_se(streq(l[0], str0));
 assert_se(streq(l[1], str1));
 assert_se(streq(l[2], str2));
@@ -117,6 +124,8 @@ static void test_strv_parse_nulstr(void) {
 const char nulstr[] = fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx;
 
 l = strv_parse_nulstr(nulstr, sizeof(nulstr)-1);
+assert_se(l);
+
 puts(Parse nulstr:);
 strv_print(l);
 
@@ -178,6 +187,10 @@ static void test_strv_merge_concat(void) {
 
 c = strv_merge_concat(a, b, _suffix);
 
+assert_se(a);
+assert_se(b);
+assert_se(c);
+
 assert_se(streq(c[0], without));
 assert_se(streq(c[1], suffix));
 assert_se(streq(c[2], with_suffix));
@@ -192,6 +205,10 @@ static void test_strv_merge(void) {
 
 c = strv_merge(a, b);
 
+assert_se(a);
+assert_se(b);
+assert_se(c);
+
 assert_se(streq(c[0], abc));
 assert_se(streq(c[1], def));
 assert_se(streq(c[2], ghi));
@@ -209,6 +226,10 @@ static void test_strv_append(void) {
 b = strv_append(a, test2);
 c = strv_append(NULL, test3);
 
+assert_se(a);
+assert_se(b);
+assert_se(c);
+
 assert_se(streq(b[0], test));
 assert_se(streq(b[1], test1));
 assert_se(streq(b[2], test2));
-- 
1.8.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 3/3] test-strv.c: ported test_specifier_printf() to _cleanup_free_ + assert_se + cleanup

2013-02-17 Thread Daniel Buch
---
 src/test/test-strv.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index e33568c..1718f56 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -27,7 +27,7 @@
 #include strv.h
 
 static void test_specifier_printf(void) {
-char *w;
+_cleanup_free_ char *w = NULL;
 
 const Specifier table[] = {
 { 'a', specifier_string, (char*)  },
@@ -36,8 +36,10 @@ static void test_specifier_printf(void) {
 };
 
 w = specifier_printf(xxx a=%a b=%b yyy, table, NULL);
-printf(%s\n, w);
-free(w);
+puts(w);
+
+assert_se(w);
+assert_se(streq(w, xxx a= b= yyy));
 }
 
 static void test_strv_find(void) {
-- 
1.8.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/4] test-strv.c: added strv_merge test

2013-02-13 Thread Daniel Buch
---
 src/test/test-strv.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 07aac3a..3ed5a09 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -158,6 +158,24 @@ static void test_strv_sort(void) {
 assert(streq(input_table[4], durian));
 }
 
+static void test_strv_merge(void) {
+ _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL;
+
+ a = strv_new(abc, def, ghi, NULL);
+ b = strv_new(jkl, mno, pqr, NULL);
+
+ c = strv_merge(a, b);
+
+ assert(streq(c[0], abc));
+ assert(streq(c[1], def));
+ assert(streq(c[2], ghi));
+ assert(streq(c[3], jkl));
+ assert(streq(c[4], mno));
+ assert(streq(c[5], pqr));
+
+ assert(strv_length(c) == 6);
+}
+
 int main(int argc, char *argv[]) {
 test_specifier_printf();
 test_strv_find();
@@ -166,6 +184,7 @@ int main(int argc, char *argv[]) {
 test_strv_parse_nulstr();
 test_strv_overlap();
 test_strv_sort();
+test_strv_merge();
 
 return 0;
 }
-- 
1.8.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/4] test-strv.c: added strv_merge_concat test

2013-02-13 Thread Daniel Buch
---
 src/test/test-strv.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 3ed5a09..fabc26e 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -158,6 +158,20 @@ static void test_strv_sort(void) {
 assert(streq(input_table[4], durian));
 }
 
+static void test_strv_merge_concat(void) {
+  _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL;
+
+ a = strv_new(without, suffix, NULL);
+ b = strv_new(with, suffix, NULL);
+
+ c = strv_merge_concat(a, b, _suffix);
+
+ assert(streq(c[0], without));
+ assert(streq(c[1], suffix));
+ assert(streq(c[2], with_suffix));
+ assert(streq(c[3], suffix_suffix));
+}
+
 static void test_strv_merge(void) {
  _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL;
 
@@ -185,6 +199,7 @@ int main(int argc, char *argv[]) {
 test_strv_overlap();
 test_strv_sort();
 test_strv_merge();
+test_strv_merge_concat();
 
 return 0;
 }
-- 
1.8.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 3/4] test-strv.c: added strv_append test

2013-02-13 Thread Daniel Buch
---
 src/test/test-strv.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index fabc26e..535685f 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -190,6 +190,19 @@ static void test_strv_merge(void) {
  assert(strv_length(c) == 6);
 }
 
+static void test_strv_append(void) {
+_cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL;
+
+a = strv_new(test, test1, NULL);
+b = strv_append(a, test2);
+c = strv_append(NULL, test3);
+
+assert(streq(b[0], test));
+assert(streq(b[1], test1));
+assert(streq(b[2], test2));
+assert(streq(c[0], test3));
+}
+
 int main(int argc, char *argv[]) {
 test_specifier_printf();
 test_strv_find();
@@ -200,6 +213,7 @@ int main(int argc, char *argv[]) {
 test_strv_sort();
 test_strv_merge();
 test_strv_merge_concat();
+test_strv_append();
 
 return 0;
 }
-- 
1.8.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 4/4] test-strv.c: Changed assert() to assert_se()

2013-02-13 Thread Daniel Buch
test-strv.c: Indent fix
---
 src/test/test-strv.c | 96 ++--
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 535685f..a8801b5 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -48,8 +48,8 @@ static void test_strv_find(void) {
 NULL
 };
 
-assert(strv_find((char **)input_table, three));
-assert(!strv_find((char **)input_table, four));
+assert_se(strv_find((char **)input_table, three));
+assert_se(!strv_find((char **)input_table, four));
 }
 
 static void test_strv_find_prefix(void) {
@@ -60,11 +60,11 @@ static void test_strv_find_prefix(void) {
 NULL
 };
 
-assert(strv_find_prefix((char **)input_table, o));
-assert(strv_find_prefix((char **)input_table, one));
-assert(strv_find_prefix((char **)input_table, ));
-assert(!strv_find_prefix((char **)input_table, xxx));
-assert(!strv_find_prefix((char **)input_table, onee));
+assert_se(strv_find_prefix((char **)input_table, o));
+assert_se(strv_find_prefix((char **)input_table, one));
+assert_se(strv_find_prefix((char **)input_table, ));
+assert_se(!strv_find_prefix((char **)input_table, xxx));
+assert_se(!strv_find_prefix((char **)input_table, onee));
 }
 
 static void test_strv_join(void) {
@@ -85,19 +85,19 @@ static void test_strv_join(void) {
 };
 
 p = strv_join((char **)input_table_multiple, , );
-assert(streq(p, one, two, three));
+assert_se(streq(p, one, two, three));
 
 q = strv_join((char **)input_table_multiple, ;);
-assert(streq(q, one;two;three));
+assert_se(streq(q, one;two;three));
 
 r = strv_join((char **)input_table_multiple, NULL);
-assert(streq(r, one two three));
+assert_se(streq(r, one two three));
 
 s = strv_join((char **)input_table_one, , );
-assert(streq(s, one));
+assert_se(streq(s, one));
 
 t = strv_join((char **)input_table_none, , );
-assert(streq(t, ));
+assert_se(streq(t, ));
 }
 
 static void test_strv_parse_nulstr(void) {
@@ -108,13 +108,13 @@ static void test_strv_parse_nulstr(void) {
 puts(Parse nulstr:);
 strv_print(l);
 
-assert(streq(l[0], fuck));
-assert(streq(l[1], fuck2));
-assert(streq(l[2], fuck3));
-assert(streq(l[3], ));
-assert(streq(l[4], fuck5));
-assert(streq(l[5], ));
-assert(streq(l[6], xxx));
+assert_se(streq(l[0], fuck));
+assert_se(streq(l[1], fuck2));
+assert_se(streq(l[2], fuck3));
+assert_se(streq(l[3], ));
+assert_se(streq(l[4], fuck5));
+assert_se(streq(l[5], ));
+assert_se(streq(l[6], xxx));
 }
 
 static void test_strv_overlap(void) {
@@ -135,8 +135,8 @@ static void test_strv_overlap(void) {
 NULL
 };
 
-assert(strv_overlap((char **)input_table, 
(char**)input_table_overlap));
-assert(!strv_overlap((char **)input_table, 
(char**)input_table_unique));
+assert_se(strv_overlap((char **)input_table, 
(char**)input_table_overlap));
+assert_se(!strv_overlap((char **)input_table, 
(char**)input_table_unique));
 }
 
 static void test_strv_sort(void) {
@@ -151,43 +151,43 @@ static void test_strv_sort(void) {
 
 strv_sort((char **)input_table);
 
-assert(streq(input_table[0], CAPITAL LETTERS FIRST));
-assert(streq(input_table[1], apple));
-assert(streq(input_table[2], banana));
-assert(streq(input_table[3], citrus));
-assert(streq(input_table[4], durian));
+assert_se(streq(input_table[0], CAPITAL LETTERS FIRST));
+assert_se(streq(input_table[1], apple));
+assert_se(streq(input_table[2], banana));
+assert_se(streq(input_table[3], citrus));
+assert_se(streq(input_table[4], durian));
 }
 
 static void test_strv_merge_concat(void) {
-  _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL;
+ _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL;
 
- a = strv_new(without, suffix, NULL);
- b = strv_new(with, suffix, NULL);
+a = strv_new(without, suffix, NULL);
+b = strv_new(with, suffix, NULL);
 
- c = strv_merge_concat(a, b, _suffix);
+c = strv_merge_concat(a, b, _suffix);
 
- assert(streq(c[0], without));
- assert(streq(c[1], suffix));
- assert(streq(c[2], with_suffix));
- assert(streq(c[3], suffix_suffix));
+assert_se(streq(c[0], without));
+assert_se(streq(c[1], suffix));
+assert_se(streq(c[2], with_suffix));
+assert_se(streq(c[3], suffix_suffix));
 }
 
 static void test_strv_merge(void) {
  _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL;
 
- a = strv_new(abc, def, ghi, 

[systemd-devel] strv tests

2013-02-11 Thread Daniel Buch
I made tests for:

strv_merge
strv_merge_concat
strv_append
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] strv tests

2013-02-11 Thread Daniel Buch
And now with patch files.


2013/2/11 Daniel Buch boogiewasth...@gmail.com

 I made tests for:

 strv_merge
 strv_merge_concat
 strv_append



0003-test-strv.c-added-strv_append-test.patch
Description: Binary data


0002-test-strv.c-added-strv_merge_concat-test.patch
Description: Binary data


0001-test-strv.c-added-strv_merge-test.patch
Description: Binary data
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] tests

2013-01-30 Thread Daniel Buch
I did some improvements on strv-test.c and added additional test, more is
on its way.

Patch files is attached.

What do you think?


0001-test-strv.c-Split-tests-into-seperate-functions.patch
Description: Binary data


0002-test-strv.c-test-strv_join-added.patch
Description: Binary data
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel