Re: [systemd-devel] [systemd-commits] src/libsystemd

2014-10-21 Thread Lennart Poettering
On Tue, 21.10.14 13:16, Daniel Mack (zon...@kemper.freedesktop.org) wrote:

  src/libsystemd/sd-bus/bus-kernel.c |   16 +---
  src/libsystemd/sd-bus/kdbus.h  |3 ++-
  2 files changed, 15 insertions(+), 4 deletions(-)
 
 New commits:
 commit 03785ad0e51b061efb9f9b3f2e328685f9a866aa
 Author: Daniel Mack dan...@zonque.org
 Date:   Tue Oct 21 22:14:03 2014 +0200
 
 sd-bus: sync kdbus.h (API change: switch to absolute timeouts)
 
 kdbus_msg.timeout_ns now takes an absolute value, based on 
 CLOCK_MONOTONIC,
 in order to eventually support automatically restarted syscalls.
 
 Signed-off-by: Daniel Mack dan...@zonque.org
 
 diff --git a/src/libsystemd/sd-bus/bus-kernel.c 
 b/src/libsystemd/sd-bus/bus-kernel.c
 index 6b5a3d3..136c90f 100644
 --- a/src/libsystemd/sd-bus/bus-kernel.c
 +++ b/src/libsystemd/sd-bus/bus-kernel.c
 @@ -270,10 +270,20 @@ static int bus_message_setup_kmsg(sd_bus *b, 
 sd_bus_message *m) {
  m-kdbus-cookie = (uint64_t) m-header-serial;
  m-kdbus-priority = m-priority;
  
 -if (m-header-flags  BUS_MESSAGE_NO_REPLY_EXPECTED)
 +if (m-header-flags  BUS_MESSAGE_NO_REPLY_EXPECTED) {
  m-kdbus-cookie_reply = m-reply_cookie;
 -else
 -m-kdbus-timeout_ns = m-timeout * NSEC_PER_USEC;
 +} else {
 +struct timespec now;
 +
 +r = clock_gettime(CLOCK_MONOTONIC_COARSE, now);

It sounds OK to enclose this in assert( == 0) really. That's what we
do in now() at least. If gettint the time fails we are massively
fucked, and we can just assert.

 +if (r  0) {
 +r = -errno;
 +goto fail;
 +}
 +
 +m-kdbus-timeout_ns = now.tv_sec * NSEC_PER_SEC + 
 now.tv_nsec +
 +   m-timeout * NSEC_PER_USEC;

I wonder if it's worth adding timspec_load_ns() or so, similar to
timespec_load() but for nsec_t instead of usec_t for this.

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-commits] src/libsystemd

2014-10-08 Thread Lennart Poettering
On Wed, 08.10.14 08:30, Daniel Mack (zon...@kemper.freedesktop.org) wrote:

  
 -/* The higher 32bit of the flags field are considered
 - * 'incompatible flags'. Refuse them all for now. */
 -if (make-flags  0xULL) {
 +/* The features field are considered 'incompatible flags'.
 + * Refuse them all for now. */
 +if (make-features) {
  safe_close(fd);
  return -ENOTSUP;

This appears the wrong way around, we discussed in Berlin yesterday
that features should be the compatible bitmask, and flags should
be the incompatible one.

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-commits] src/libsystemd-network src/systemd

2014-04-29 Thread Lennart Poettering
On Tue, 29.04.14 03:27, Tom Gundersen (tome...@kemper.freedesktop.org) wrote:

 +case DHCP_OPTION_NTP_SERVER:
 +if (len  !(len % 4)) {
 +unsigned i;
 +
 +lease-ntp_size = len / 4;
 +
 +free(lease-ntp);
 +lease-ntp = new0(struct in_addr, lease-ntp_size);
 +if (!lease-ntp)
 +return -ENOMEM;
 +
 +for (i = 0; i  lease-ntp_size; i++) {
 +memcpy(lease-ntp[i].s_addr, option + 4 * 
 i, 4);
 +}

This should be shorter, no?

lease-ntp = newdup(struct in_addr, option, lease-ntp_size);
if (!lease-ntp) ...

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-commits] src/libsystemd-network src/systemd

2014-04-29 Thread Tom Gundersen
On Tue, Apr 29, 2014 at 12:37 PM, Lennart Poettering
lenn...@poettering.net wrote:
 On Tue, 29.04.14 03:27, Tom Gundersen (tome...@kemper.freedesktop.org) wrote:

 +case DHCP_OPTION_NTP_SERVER:
 +if (len  !(len % 4)) {
 +unsigned i;
 +
 +lease-ntp_size = len / 4;
 +
 +free(lease-ntp);
 +lease-ntp = new0(struct in_addr, lease-ntp_size);
 +if (!lease-ntp)
 +return -ENOMEM;
 +
 +for (i = 0; i  lease-ntp_size; i++) {
 +memcpy(lease-ntp[i].s_addr, option + 4 * 
 i, 4);
 +}

 This should be shorter, no?

 lease-ntp = newdup(struct in_addr, option, lease-ntp_size);
 if (!lease-ntp) ...

Oh, cool, didn't know about that one.

Will fix.

Cheers,

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


Re: [systemd-devel] [systemd-commits] src/libsystemd-dhcp src/systemd

2014-01-16 Thread Lennart Poettering
On Mon, 06.01.14 03:35, Tom Gundersen (tome...@kemper.freedesktop.org) wrote:

 +lease-dns = new0(struct in_addr*, len / 4 + 1);
 +if (!lease-dns)
 +return -ENOMEM;
 +
 +for (i = 0; i  len / 4; i++) {
 +lease-dns[i] = new0(struct in_addr, 1);
 +memcpy(lease-dns[i]-s_addr, option + 4 * 
 i, 4);
 +}
 +
 +lease-dns[i + 1] = NULL;

Isn't this a bit overkill? Why not just use an array of struct in_addr
rather than an array of struct in_addr*? I mean, even if we'd ignore
the overhead of malloc() here, the code is a lot more complex, and on
64bit you use double the memory for storing the pointer to the address
than for the actual address stored... ;-)

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-commits] src/libsystemd-dhcp src/systemd

2014-01-16 Thread Tom Gundersen
On Thu, Jan 16, 2014 at 5:35 PM, Lennart Poettering
lenn...@poettering.net wrote:
 On Mon, 06.01.14 03:35, Tom Gundersen (tome...@kemper.freedesktop.org) wrote:

 +lease-dns = new0(struct in_addr*, len / 4 + 1);
 +if (!lease-dns)
 +return -ENOMEM;
 +
 +for (i = 0; i  len / 4; i++) {
 +lease-dns[i] = new0(struct in_addr, 1);
 +memcpy(lease-dns[i]-s_addr, option + 4 * 
 i, 4);
 +}
 +
 +lease-dns[i + 1] = NULL;

 Isn't this a bit overkill? Why not just use an array of struct in_addr
 rather than an array of struct in_addr*? I mean, even if we'd ignore
 the overhead of malloc() here, the code is a lot more complex, and on
 64bit you use double the memory for storing the pointer to the address
 than for the actual address stored... ;-)

Fair enough :-) Fixed locally, will push soon.

Cheers,

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