X-Git-Url: http://git.tuebingen.mpg.de/?p=osl.git;a=blobdiff_plain;f=util.c;h=34667e3fc7a6ace461652ec90c285b60bdb47307;hp=49f1914e81e59a2648a9cb9af364ad1d98ac58cd;hb=HEAD;hpb=c9d2589c6764a308142afd17e92cef630c7fe940;ds=sidebyside diff --git a/util.c b/util.c index 49f1914..34667e3 100644 --- a/util.c +++ b/util.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2009 Andre Noll + * Copyright (C) 2006-2009 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -110,9 +110,11 @@ int write_file(const char *filename, const void *buf, size_t size) if (ret < 0) return ret; fd = ret; - ret = write_all(fd, buf, &size); - if (ret < 0) - goto out; + if (size != 0) { + ret = write_all(fd, buf, &size); + if (ret < 0) + goto out; + } ret = 1; out: close(fd); @@ -227,7 +229,7 @@ __must_check __printf_1_2 __malloc char *make_message(const char *fmt, ...) n = vsnprintf(p, size, fmt, ap); va_end(ap); /* If that worked, return the string. */ - if (n > -1 && n < size) + if (n > -1 && (unsigned)n < size) break; /* Else try again with more space. */ if (n > -1) /* glibc 2.1 */