]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfsprogs: libxcmd: isolate strdup() calls to fs_table_insert()
authorAlex Elder <aelder@sgi.com>
Mon, 3 Oct 2011 12:49:18 +0000 (12:49 +0000)
committerAlex Elder <aelder@sgi.com>
Thu, 6 Oct 2011 20:19:30 +0000 (15:19 -0500)
commit1f4e1f7f0d66f583f3c7c943628cf8fb857606fc
treece1d469081591986116b349cb54b7a74dca3a7a3
parent0900efe40df790d6696023dc0578306a4db487e6
xfsprogs: libxcmd: isolate strdup() calls to fs_table_insert()

Calls to fs_table_insert() are made in four places, and in all four
the mount directory and device name arguments passed are the result
of calls to strdup().  Rather than have all the callers handle
allocating and freeing of these strings, consolidate that into
fs_table_insert().

Only one place passes non-null values for the fslog and fsrt
arguments, and in that case it's easier to keep the allocation of
duplicate strings where they are in the caller.  Add a comment in
fs_table_insert() to ensure that's understood.

Note also that fs_table_insert() is always called with both its
dir and fsname arguments non-null, so drop a check for that at
the top of the function.

Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxcmd/paths.c