libnfs.h: add include guards

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
libnfs-raw.h: remove trailing whitespace

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
libnfs-private.h: add include guards

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
slist.h: add include guards

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
libnfs-private.h: wrap in extern "C" for C++ compatibility

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
libnfs-raw.h: wrap in extern "C" for C++ compatibility

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
libnfs-zdr.h: wrap in extern "C" for C++ compatibility

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_normalize_path: fix using the results of assignments in while loops

Spotted by clang:
 ../../libnfs.git/lib/libnfs.c:1002:13: warning: using the result of an assignment as a condition without parentheses
       [-Wparentheses]
         while (str = strstr(path, "//")) {
                ~~~~^~~~~~~~~~~~~~~~~~~~
 ../../libnfs.git/lib/libnfs.c:1002:13: note: place parentheses around the assignment to silence this warning
         while (str = strstr(path, "//")) {
                    ^
                (                       )
 ../../libnfs.git/lib/libnfs.c:1002:13: note: use '==' to turn this assignment into an equality comparison
         while (str = strstr(path, "//")) {
                    ^
                    ==

Make the intent clear by adding extra parentheses, and also
remove trailing whitespace from libnfs.c while at it.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
libnfs.h: wrap in extern "C" for C++ compatibility

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
libnfs-raw.h: rename export -> exportname to avoid clash with C++ keyword

From http://en.cppreference.com/w/cpp/keyword/export :

  Until C++11:
  "Used to mark a template definition exported, which allows the same
   template to be declared, but not defined, in other translation units."

  Since C++11:
  "The keyword is unused and reserved."

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_opendir_cb: plug potential memory leak

Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_lookuppath_async: plug potential memleak

Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_mknod_async: plug potential memory leak

Pointed out by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_creat_async: plug potential memleak

Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_fchown_async: plug potential memleak

Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_fchown_async: fix nullptr dereference

nfs_chown_data is hooked up under nfs_cb_data->continue_data but
no ->free_continue_data is configured, so once free_nfs_cb_data is
invoked it will trip over a nullptr.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
free_nfs_cb_data: add assert(data->free_continue_data)

Non-debug builds will trip over the nullptr too - do we rather
want to leak the memory there?

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
free_nfs_cb_data: make static and drop superfluous nullptr checks / assignments

free() can cope with nullptrs and there's no point in null-ing free'd members
as the containing struct is free'd as well.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_opendir2_cb: plug potential memleaks

Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
nfs_fchmod_async: fix use-after-free

Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>