[systemd-devel] [systemd-commits] 2 commits - src/nspawn src/shared
Tom Gundersen
teg at jklm.no
Tue Sep 30 03:25:56 PDT 2014
On Mon, Sep 29, 2014 at 9:51 PM, Zbigniew Jędrzejewski-Szmek
<zbyszek at in.waw.pl> wrote:
> On Mon, Sep 29, 2014 at 11:55:09AM -0700, Tom Gundersen wrote:
>> src/nspawn/nspawn.c | 13 ++++++++++---
>> src/shared/util.c | 18 ++++++++++++++----
>> 2 files changed, 24 insertions(+), 7 deletions(-)
>>
>> New commits:
>> commit 9fb02b1d5df153aa522256aec821e422cca7f284
>> Author: Tom Gundersen <teg at jklm.no>
>> Date: Mon Sep 29 14:30:15 2014 +0200
>>
>> util: silence coverity
>>
>> Make it clear in the code that ignoring a failed safe_ato?() is intentional.
>>
>> diff --git a/src/shared/util.c b/src/shared/util.c
>> index 30b0364..ec33fc1 100644
>> --- a/src/shared/util.c
>> +++ b/src/shared/util.c
>> @@ -3272,8 +3272,13 @@ unsigned columns(void) {
>>
>> c = 0;
>> e = getenv("COLUMNS");
>> - if (e)
>> - safe_atoi(e, &c);
>> + if (e) {
>> + int r;
>> +
>> + r = safe_atoi(e, &c);
>> + if (r < 0) {}
>> + /* do nothing, we fall back to c = 0 */
> Why not just say:
> (void) safe_atoi(e, &c);
Yeah, that is much nicer. I changed it.
Thanks!
Tom
> Zbyszek
>
>> + }
>>
>> if (c <= 0)
>> c = fd_columns(STDOUT_FILENO);
>> @@ -3306,8 +3311,13 @@ unsigned lines(void) {
>>
>> l = 0;
>> e = getenv("LINES");
>> - if (e)
>> - safe_atou(e, &l);
>> + if (e) {
>> + int r;
>> +
>> + r = safe_atou(e, &l);
>> + if (r < 0) {}
>> + /* do nothing, we fall back to l = 0 */
>> + }
>>
>> if (l <= 0)
>> l = fd_lines(STDOUT_FILENO);
>>
>> commit e8c8ddccfc63574069c30b7e75f0ccfd5b03eab9
>> Author: Tom Gundersen <teg at jklm.no>
>> Date: Mon Sep 29 13:20:54 2014 +0200
>>
>> nspawn: log when tearing down of loop device fails
>>
>> diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
>> index 4c1cfab..34436b8 100644
>> --- a/src/nspawn/nspawn.c
>> +++ b/src/nspawn/nspawn.c
>> @@ -2607,20 +2607,27 @@ static int mount_devices(
>>
>> static void loop_remove(int nr, int *image_fd) {
>> _cleanup_close_ int control = -1;
>> + int r;
>>
>> if (nr < 0)
>> return;
>>
>> if (image_fd && *image_fd >= 0) {
>> - ioctl(*image_fd, LOOP_CLR_FD);
>> + r = ioctl(*image_fd, LOOP_CLR_FD);
>> + if (r < 0)
>> + log_warning("Failed to close loop image: %m");
>> *image_fd = safe_close(*image_fd);
>> }
>>
>> control = open("/dev/loop-control", O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
>> - if (control < 0)
>> + if (control < 0) {
>> + log_warning("Failed to open /dev/loop-control: %m");
>> return;
>> + }
>>
>> - ioctl(control, LOOP_CTL_REMOVE, nr);
>> + r = ioctl(control, LOOP_CTL_REMOVE, nr);
>> + if (r < 0)
>> + log_warning("Failed to remove loop %d: %m", nr);
>> }
>>
>> static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
>>
>> _______________________________________________
>> systemd-commits mailing list
>> systemd-commits at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/systemd-commits
>>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list