Commit Graph

23 Commits

Author SHA1 Message Date
Sami Kerola 273ebba11d include/xalloc: reindent function bodies to unify indentation
The file used unusual 7 spaces indent step in some of the functions.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-21 15:00:16 +02:00
Sami Kerola aba9e76e25 include/xalloc: use multiline function declarations
There are two things happening in this commit.  1) Move each function
attribute to it's own line 2) move function return value after attributes so
that function inputs and outputs are on same line.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-21 15:00:16 +02:00
Sami Kerola f3aded3fdb
include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attribute
Turned out lsblk is passing null as argument to xstrdup(), so fix that and
add assert() to make sure promise of not returning null is kept in future.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-14 11:52:13 +01:00
Sami Kerola e73456dfbb include: add no return function attribute
This warning is repeated 112 times when compiling with all warnings.

xalloc.h:23:1: warning: function '__err_oom' could be declared with
attribute 'noreturn' [-Wmissing-noreturn]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:21:23 +01:00
Sami Kerola f1b327f8d5
include/c: use returns_nonnull function attribute in xalloc.h
Let the compiler optimize based on the knowledge that the return value will
never be null.

Reference: https://patchwork.ozlabs.org/patch/281112/#631159
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-11-21 20:54:18 +00:00
Karel Zak 16c9f32f07 include/xalloc: add err_oom()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Rainer Gerhards 3eb3c8d77e silence compiler warning
This is primarily cosmetic, albeit it also provides an only very
slight improvement in compile time error checking.
2015-03-10 14:13:38 +01:00
Karel Zak 2e6c3a53f9 include/xalloc: add xvasprintf()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak c9678832b1 include/xalloc: add warn_unused_result to allocation functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-09 10:44:06 +02:00
Karel Zak 2b88d3d72b lib/xalloc: add xstrndup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-10 17:16:01 +02:00
Karel Zak 8362545b4a lib/xalloc: fix mamory leak in xgethostname() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:08:47 +01:00
Karel Zak 1b2aa6293d include/xalloc: add xgethostname()
The new function allocates memory by xalloc() for hostname and
fill in the buffer by gethostname().

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 16:23:54 +02:00
Sami Kerola d0aa8a446d include: define format to be constant in xasprintf()
Add also format function attribute to add robustness.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:24 +02:00
Sami Kerola eeb31db9b9 include: add asprintf wrapper
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Dave Reisner 12218ccde2 include,xalloc: fix whitespace to be consistent
We use spaces for the rest of this file, so the random tabs within
xstrdup stand out.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-30 00:24:16 +02:00
Dave Reisner 8ddb6b0cae include,xalloc: check for NULL before calling strdup
This fixes a segfault in mount (and possibly elsewhere) when invoked
without a -t parameter.

Broken in 7ef9fd7 when the common xalloc.h libs were introduced.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-30 00:24:05 +02:00
Petr Uzel 8ba013af64 include: [xalloc.h]: mention strdup in the file description
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-21 14:41:37 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Marek Polacek b45fa8b2f1 include: [xalloc.h] include string.h
xalloc.h needs string.h for declaration of strdup().  Otherwise we
can get implicit declaration warning.  This patch prevents it.

Signed-off-by: Marek Polacek <mpolacek@redhat.com>
2011-02-07 17:46:15 +01:00
Karel Zak 40084d0d5c include: [c.h] add fallback for alloc_size attributes
Reported-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-07 17:29:47 +01:00
Karel Zak 3e27b34eb0 lib: [xalloc] don't use hardcoded return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-23 21:28:19 +01:00
Karel Zak ecc264bc39 lib: [xalloc] add xstrdup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:32 +01:00
Davidlohr Bueso d7df7ba264 xalloc: general purpose memory allocation handling wrappers
[kzak@redhat.com: - use %zu for size_t]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-10-21 10:28:05 +02:00