]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add function attributes to private API
authorOndrej Oprala <ooprala@redhat.com>
Fri, 30 Nov 2012 08:01:10 +0000 (09:01 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 30 Nov 2012 09:34:08 +0000 (10:34 +0100)
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/cache.c
libmount/src/context.c
libmount/src/mountP.h
libmount/src/utils.c

index 34419cb6279d2d9907d1680d948f04bf9e275f8a..2a8077c3a530e1371ce338414dea039f8e553e67 100644 (file)
@@ -342,7 +342,7 @@ int mnt_cache_device_has_tag(struct libmnt_cache *cache, const char *devname,
 {
        const char *path = cache_find_tag(cache, token, value);
 
-       if (path && strcmp(path, devname) == 0)
+       if (path && devname && strcmp(path, devname) == 0)
                return 1;
        return 0;
 }
index 721c497ef67e90731ea219000ce958aa4fb3be1d..21c64726f9af390e7e814aba0fed842bb340b826 100644 (file)
@@ -1094,7 +1094,8 @@ struct libmnt_cache *mnt_context_get_cache(struct libmnt_context *cxt)
  * @get: callback to get password
  * @release: callback to release (delallocate) password
  *
- * Sets callbacks for encryption password (e.g encrypted loopdev)
+ * Sets callbacks for encryption password (e.g encrypted loopdev). This
+ * function is deprecated (encrypted loops are no ore supported).
  *
  * Returns: 0 on success, negative number in case of error.
  */
@@ -1795,7 +1796,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
                "trying to apply fstab (src=%s, target=%s)", src, tgt));
 
        /* let's initialize cxt->fs */
-       mnt_context_get_fs(cxt);
+       ignore_result( mnt_context_get_fs(cxt) );
 
        /* try fstab */
        if (cxt->optsmode & MNT_OMODE_FSTAB) {
index 04dd077a811d357500625c5bd83fde1d5da94ab9..be583469e27e69a4a85d6e40413e43d2f1f72918 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * mountP.h - private library header file
  *
- * Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
+ * Copyright (C) 2008-2012 Karel Zak <kzak@redhat.com>
  *
  * This file may be redistributed under the terms of the
  * GNU Lesser General Public License.
@@ -123,43 +123,56 @@ struct libmnt_test {
 };
 
 /* test.c */
-extern int mnt_run_test(struct libmnt_test *tests, int argc, char *argv[]);
+extern int mnt_run_test(struct libmnt_test *tests, int argc, char *argv[])
+                       __attribute__((nonnull));
 #endif
 
 /* utils.c */
-extern int endswith(const char *s, const char *sx);
-extern int startswith(const char *s, const char *sx);
+extern int endswith(const char *s, const char *sx)
+                       __attribute__((nonnull));
+extern int startswith(const char *s, const char *sx)
+                       __attribute__((nonnull));
+extern int mnt_is_readonly(const char *path)
+                       __attribute__((nonnull));
+extern int mnt_parse_offset(const char *str, size_t len, uintmax_t *res)
+                       __attribute__((nonnull(1,3)));
+
+extern int mnt_chdir_to_parent(const char *target, char **filename)
+                       __attribute__((nonnull));
 
-extern int mnt_is_readonly(const char *path);
-
-extern int mnt_parse_offset(const char *str, size_t len, uintmax_t *res);
-
-extern int mnt_chdir_to_parent(const char *target, char **filename);
 extern char *mnt_get_username(const uid_t uid);
-extern int mnt_get_uid(const char *username, uid_t *uid);
-extern int mnt_get_gid(const char *groupname, gid_t *gid);
+extern int mnt_get_uid(const char *username, uid_t *uid)
+                       __attribute__((nonnull));
+extern int mnt_get_gid(const char *groupname, gid_t *gid)
+                       __attribute__((nonnull));
 extern int mnt_in_group(gid_t gid);
 
-extern char *mnt_get_fs_root(const char *path, const char *mountpoint);
-extern int mnt_open_uniq_filename(const char *filename, char **name);
+extern char *mnt_get_fs_root(const char *path, const char *mountpoint)
+                       __attribute__((nonnull(1)));
+extern int mnt_open_uniq_filename(const char *filename, char **name)
+                       __attribute__((nonnull(1)));
+
 extern int mnt_has_regular_utab(const char **utab, int *writable);
 extern const char *mnt_get_utab_path(void);
 
-extern int mnt_get_filesystems(char ***filesystems, const char *pattern);
+extern int mnt_get_filesystems(char ***filesystems, const char *pattern)
+                       __attribute__((nonnull(1)));
 extern void mnt_free_filesystems(char **filesystems);
 
-extern char *mnt_get_kernel_cmdline_option(const char *name);
+extern char *mnt_get_kernel_cmdline_option(const char *name)
+                       __attribute__((nonnull));
 
 /* tab.c */
 extern int mnt_table_set_parser_fltrcb(        struct libmnt_table *tb,
                                        int (*cb)(struct libmnt_fs *, void *),
-                                       void *data);
+                                       void *data)
+                       __attribute__((nonnull(1)));
 
 extern struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb,
                                         struct libmnt_fs *fs,
                                         unsigned long mountflags,
-                                        char **fsroot);
-
+                                        char **fsroot)
+                       __attribute__((nonnull(2, 4)));
 /*
  * Generic iterator
  */
@@ -262,7 +275,8 @@ struct libmnt_table {
        struct list_head        ents;   /* list of entries (libmnt_fs) */
 };
 
-extern struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt);
+extern struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt)
+                       __attribute__((nonnull(1)));
 
 /*
  * Tab file format
@@ -368,53 +382,79 @@ struct libmnt_context
 #define MNT_FL_DEFAULT         0
 
 /* lock.c */
-extern int mnt_lock_use_simplelock(struct libmnt_lock *ml, int enable);
+extern int mnt_lock_use_simplelock(struct libmnt_lock *ml, int enable)
+                       __attribute__((nonnull(1)));
 
 /* optmap.c */
 extern const struct libmnt_optmap *mnt_optmap_get_entry(
                             struct libmnt_optmap const **maps,
-                             int nmaps, const char *name,
+                             int nmaps,
+                            const char *name,
                              size_t namelen,
-                            const struct libmnt_optmap **mapent);
+                            const struct libmnt_optmap **mapent)
+                       __attribute__((nonnull(1, 3)));
 
 /* optstr.c */
-extern int mnt_optstr_remove_option_at(char **optstr, char *begin, char *end);
-extern int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next);
-extern int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next);
-extern int mnt_optstr_fix_secontext(char **optstr, char *value, size_t valsz, char **next);
-extern int mnt_optstr_fix_user(char **optstr);
+extern int mnt_optstr_remove_option_at(char **optstr, char *begin, char *end)
+                       __attribute__((nonnull));
+extern int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next)
+                       __attribute__((nonnull));
+extern int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next)
+                       __attribute__((nonnull));
+extern int mnt_optstr_fix_secontext(char **optstr, char *value, size_t valsz, char **next)
+                       __attribute__((nonnull));
+extern int mnt_optstr_fix_user(char **optstr)
+                       __attribute__((nonnull));
 
 /* fs.c */
-extern struct libmnt_fs *mnt_copy_mtab_fs(const struct libmnt_fs *fs);
-extern int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source);
-extern int __mnt_fs_set_fstype_ptr(struct libmnt_fs *fs, char *fstype);
+extern struct libmnt_fs *mnt_copy_mtab_fs(const struct libmnt_fs *fs)
+                       __attribute__((nonnull));
+extern int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source)
+                       __attribute__((nonnull(1)));
+extern int __mnt_fs_set_fstype_ptr(struct libmnt_fs *fs, char *fstype)
+                       __attribute__((nonnull(1)));
 
 /* context.c */
-extern int mnt_context_prepare_srcpath(struct libmnt_context *cxt);
-extern int mnt_context_prepare_target(struct libmnt_context *cxt);
-extern int mnt_context_guess_fstype(struct libmnt_context *cxt);
+extern int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
+extern int mnt_context_prepare_target(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
+extern int mnt_context_guess_fstype(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
 extern int mnt_context_prepare_helper(struct libmnt_context *cxt,
-                                     const char *name, const char *type);
-extern int mnt_context_prepare_update(struct libmnt_context *cxt);
-extern int mnt_context_merge_mflags(struct libmnt_context *cxt);
-extern int mnt_context_update_tabs(struct libmnt_context *cxt);
-
-extern int mnt_context_umount_setopt(struct libmnt_context *cxt, int c, char *arg);
-extern int mnt_context_mount_setopt(struct libmnt_context *cxt, int c, char *arg);
-
-extern int mnt_context_is_loopdev(struct libmnt_context *cxt);
-extern int mnt_context_setup_loopdev(struct libmnt_context *cxt);
-extern int mnt_context_delete_loopdev(struct libmnt_context *cxt);
-extern int mnt_context_clear_loopdev(struct libmnt_context *cxt);
+                                     const char *name, const char *type)
+                       __attribute__((nonnull(1,2)));
+extern int mnt_context_prepare_update(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
+extern int mnt_context_merge_mflags(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
+extern int mnt_context_update_tabs(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
+
+extern int mnt_context_umount_setopt(struct libmnt_context *cxt, int c, char *arg)
+                       __attribute__((nonnull(1)));
+extern int mnt_context_mount_setopt(struct libmnt_context *cxt, int c, char *arg)
+                       __attribute__((nonnull(1)));
+
+extern int mnt_context_is_loopdev(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
+extern int mnt_context_setup_loopdev(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
+extern int mnt_context_delete_loopdev(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
+extern int mnt_context_clear_loopdev(struct libmnt_context *cxt)
+                       __attribute__((nonnull));
 
 extern int mnt_fork_context(struct libmnt_context *cxt);
 
 extern int mnt_context_set_tabfilter(struct libmnt_context *cxt,
-                       int (*fltr)(struct libmnt_fs *, void *),
-                       void *data);
+                                    int (*fltr)(struct libmnt_fs *, void *),
+                                    void *data)
+                       __attribute__((nonnull(1)));
 
 /* tab_update.c */
 extern int mnt_update_set_filename(struct libmnt_update *upd,
-                                  const char *filename, int userspace_only);
+                                  const char *filename, int userspace_only)
+                       __attribute__((nonnull(1)));
 
 #endif /* _LIBMOUNT_PRIVATE_H */
index 28eca7c82fee6dac115e635eb81785eeff8d72da..74c3ad509a4b6c5a34b2719bd51f0969ca35bda6 100644 (file)
@@ -836,7 +836,7 @@ int mnt_open_uniq_filename(const char *filename, char **name)
  * This function finds the mountpoint that a given path resides in. @path
  * should be canonicalized. The returned pointer should be freed by the caller.
  *
- * Returns: target of mounted device or NULL on error
+ * Returns: allocated string with target of the mounted device or NULL on error
  */
 char *mnt_get_mountpoint(const char *path)
 {