btrfs-progs: simplify ioctl name copy and null termination
authorEric Sandeen <sandeen@redhat.com>
Fri, 25 Jan 2013 19:27:47 +0000 (13:27 -0600)
committerZach Brown <zab@redhat.com>
Wed, 6 Feb 2013 00:09:41 +0000 (16:09 -0800)
commitbcb2b73358f1c05e6b5c48cfd19e3762cc69c677
tree0527a68a1c20f3777f1c5f3559e29c424fb4dde4
parent7ced17b07f9524c999395240458a46e403036d6b
btrfs-progs: simplify ioctl name copy and null termination

In the places where we copy a string into the name
member of btrfs_ioctl_vol_args or btrfs_ioctl_vol_args_v2,
we use strncopy (to not overflow the name array) and then
set the last position to the null character.

Howver, in both cases the arrays are defined with:

        char name[MAX+1];

hence the last array position is name[MAX].

In most cases, we now insert the null at name[MAX-1]
which deprives us of one useful character.

Even the above isn't consistent through the code, so
make some helper code to make it simple, i.e.
strncpy_null(dest, src) which automatically does the
right thing based on the size of dest.

Thanks to Zach Brown for the macro suggestion.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
btrfsctl.c
cmds-device.c
cmds-filesystem.c
cmds-subvolume.c
utils.c
utils.h