Merge "fs_mgr: fix clang static analyzer warning"

This commit is contained in:
Treehugger Robot 2017-01-24 20:58:17 +00:00 committed by Gerrit Code Review
commit d945f27cd6
3 changed files with 17 additions and 12 deletions

View file

@ -407,7 +407,7 @@ static int __mount(const char *source, const char *target, const struct fstab_re
return ret; return ret;
} }
static int fs_match(char *in1, char *in2) static int fs_match(const char *in1, const char *in2)
{ {
char *n1; char *n1;
char *n2; char *n2;
@ -837,7 +837,7 @@ int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
* If multiple fstab entries are to be mounted on "n_name", it will try to mount each one * If multiple fstab entries are to be mounted on "n_name", it will try to mount each one
* in turn, and stop on 1st success, or no more match. * in turn, and stop on 1st success, or no more match.
*/ */
int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device, int fs_mgr_do_mount(struct fstab *fstab, const char *n_name, char *n_blk_device,
char *tmp_mount_point) char *tmp_mount_point)
{ {
int i = 0; int i = 0;

View file

@ -14,12 +14,17 @@
* limitations under the License. * limitations under the License.
*/ */
#define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <libgen.h>
#include "fs_mgr_priv.h" #include "fs_mgr_priv.h"
#ifdef _LIBGEN_H
#warning "libgen.h must not be included"
#endif
char *me = ""; char *me = "";
static void usage(void) static void usage(void)
@ -32,10 +37,10 @@ static void usage(void)
* and exit the program, do not return to the caller. * and exit the program, do not return to the caller.
* Return the number of argv[] entries consumed. * Return the number of argv[] entries consumed.
*/ */
static void parse_options(int argc, char *argv[], int *a_flag, int *u_flag, int *n_flag, static void parse_options(int argc, char * const argv[], int *a_flag, int *u_flag, int *n_flag,
char **n_name, char **n_blk_dev) const char **n_name, const char **n_blk_dev)
{ {
me = basename(strdup(argv[0])); me = basename(argv[0]);
if (argc <= 1) { if (argc <= 1) {
usage(); usage();
@ -75,14 +80,14 @@ static void parse_options(int argc, char *argv[], int *a_flag, int *u_flag, int
return; return;
} }
int main(int argc, char *argv[]) int main(int argc, char * const argv[])
{ {
int a_flag=0; int a_flag=0;
int u_flag=0; int u_flag=0;
int n_flag=0; int n_flag=0;
char *n_name=NULL; const char *n_name=NULL;
char *n_blk_dev=NULL; const char *n_blk_dev=NULL;
char *fstab_file=NULL; const char *fstab_file=NULL;
struct fstab *fstab=NULL; struct fstab *fstab=NULL;
klog_set_level(6); klog_set_level(6);
@ -97,7 +102,7 @@ int main(int argc, char *argv[])
if (a_flag) { if (a_flag) {
return fs_mgr_mount_all(fstab, MOUNT_MODE_DEFAULT); return fs_mgr_mount_all(fstab, MOUNT_MODE_DEFAULT);
} else if (n_flag) { } else if (n_flag) {
return fs_mgr_do_mount(fstab, n_name, n_blk_dev, 0); return fs_mgr_do_mount(fstab, n_name, (char *)n_blk_dev, 0);
} else if (u_flag) { } else if (u_flag) {
return fs_mgr_unmount_all(fstab); return fs_mgr_unmount_all(fstab);
} else { } else {

View file

@ -99,7 +99,7 @@ int fs_mgr_mount_all(struct fstab *fstab, int mount_mode);
#define FS_MGR_DOMNT_FAILED (-1) #define FS_MGR_DOMNT_FAILED (-1)
#define FS_MGR_DOMNT_BUSY (-2) #define FS_MGR_DOMNT_BUSY (-2)
int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device, int fs_mgr_do_mount(struct fstab *fstab, const char *n_name, char *n_blk_device,
char *tmp_mount_point); char *tmp_mount_point);
int fs_mgr_do_tmpfs_mount(char *n_name); int fs_mgr_do_tmpfs_mount(char *n_name);
int fs_mgr_unmount_all(struct fstab *fstab); int fs_mgr_unmount_all(struct fstab *fstab);