From 08c067a352f53bbf8b07a1305c8625435ec6e410 Mon Sep 17 00:00:00 2001 From: josch Date: Sun, 21 Sep 2014 15:59:52 +0200 Subject: [PATCH] add const qualifiers to some variables --- mfapi/apicalls.h | 10 +++--- mfapi/apicalls/file_get_info.c | 10 +++--- mfapi/apicalls/file_get_links.c | 10 +++--- mfapi/apicalls/folder_create.c | 4 +-- mfapi/apicalls/folder_delete.c | 4 +-- mfapi/apicalls/folder_get_content.c | 4 +-- mfapi/apicalls/folder_get_info.c | 10 +++--- mfapi/apicalls/user_get_info.c | 10 +++--- mfapi/apicalls/user_session.c | 13 ++++---- mfapi/file.c | 6 ++-- mfapi/file.h | 2 +- mfapi/mfconn.c | 27 ++++++++-------- mfapi/mfconn.h | 19 +++++++----- mfshell/commands.h | 48 +++++++++++++++++++---------- mfshell/commands/auth.c | 2 +- mfshell/commands/chdir.c | 2 +- mfshell/commands/debug.c | 2 +- mfshell/commands/file.c | 2 +- mfshell/commands/get.c | 2 +- mfshell/commands/help.c | 2 +- mfshell/commands/host.c | 2 +- mfshell/commands/lcd.c | 2 +- mfshell/commands/links.c | 2 +- mfshell/commands/list.c | 2 +- mfshell/commands/lpwd.c | 2 +- mfshell/commands/mkdir.c | 2 +- mfshell/commands/pwd.c | 2 +- mfshell/commands/rmdir.c | 2 +- mfshell/commands/whoami.c | 2 +- mfshell/main.c | 6 ++-- mfshell/mfshell.c | 2 +- mfshell/mfshell.h | 4 +-- tests/valgrind.sh | 2 +- 33 files changed, 123 insertions(+), 98 deletions(-) diff --git a/mfapi/apicalls.h b/mfapi/apicalls.h index 935b92d..0c947d1 100644 --- a/mfapi/apicalls.h +++ b/mfapi/apicalls.h @@ -43,10 +43,12 @@ int mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, int mfconn_api_user_get_info(mfconn * conn); -int mfconn_api_user_get_session_token(mfconn * conn, char *server, - char *username, - char *password, int app_id, - char *app_key, +int mfconn_api_user_get_session_token(mfconn * conn, + const char *server, + const char *username, + const char *password, + int app_id, + const char *app_key, uint32_t * secret_key, char **secret_time, char **session_token); diff --git a/mfapi/apicalls/file_get_info.c b/mfapi/apicalls/file_get_info.c index e424e97..b7d98c9 100644 --- a/mfapi/apicalls/file_get_info.c +++ b/mfapi/apicalls/file_get_info.c @@ -32,7 +32,7 @@ static int _decode_file_get_info(mfhttp * conn, void *data); int mfconn_api_file_get_info(mfconn * conn, mffile * file, char *quickkey) { - char *api_call; + const char *api_call; int retval; int len; mfhttp *http; @@ -59,7 +59,7 @@ int mfconn_api_file_get_info(mfconn * conn, mffile * file, char *quickkey) retval = http_get_buf(http, api_call, _decode_file_get_info, file); http_destroy(http); - free(api_call); + free((void *)api_call); return retval; } @@ -86,15 +86,15 @@ static int _decode_file_get_info(mfhttp * conn, void *data) quickkey = json_object_get(node, "quickkey"); if (quickkey != NULL) - file_set_key(file, (char *)json_string_value(quickkey)); + file_set_key(file, json_string_value(quickkey)); file_name = json_object_get(node, "filename"); if (file_name != NULL) - file_set_name(file, (char *)json_string_value(file_name)); + file_set_name(file, json_string_value(file_name)); file_hash = json_object_get(node, "hash"); if (file_hash != NULL) { - file_set_hash(file, (char *)json_string_value(file_hash)); + file_set_hash(file, json_string_value(file_hash)); } if (quickkey == NULL) diff --git a/mfapi/apicalls/file_get_links.c b/mfapi/apicalls/file_get_links.c index a75c950..f42e54b 100644 --- a/mfapi/apicalls/file_get_links.c +++ b/mfapi/apicalls/file_get_links.c @@ -32,7 +32,7 @@ static int _decode_file_get_links(mfhttp * conn, void *data); int mfconn_api_file_get_links(mfconn * conn, mffile * file, char *quickkey) { - char *api_call; + const char *api_call; int retval; int len; mfhttp *http; @@ -59,7 +59,7 @@ int mfconn_api_file_get_links(mfconn * conn, mffile * file, char *quickkey) retval = http_get_buf(http, api_call, _decode_file_get_links, file); http_destroy(http); - free(api_call); + free((void *)api_call); return retval; } @@ -96,15 +96,15 @@ static int _decode_file_get_links(mfhttp * conn, void *data) quickkey = json_object_get(node, "quickkey"); if (quickkey != NULL) - file_set_key(file, (char *)json_string_value(quickkey)); + file_set_key(file, json_string_value(quickkey)); share_link = json_object_get(node, "normal_download"); if (share_link != NULL) - file_set_share_link(file, (char *)json_string_value(share_link)); + file_set_share_link(file, json_string_value(share_link)); direct_link = json_object_get(node, "direct_download"); if (direct_link != NULL) { - file_set_direct_link(file, (char *)json_string_value(direct_link)); + file_set_direct_link(file, json_string_value(direct_link)); } onetime_link = json_object_get(node, "one_time_download"); diff --git a/mfapi/apicalls/folder_create.c b/mfapi/apicalls/folder_create.c index 1b8dd5d..f288fc3 100644 --- a/mfapi/apicalls/folder_create.c +++ b/mfapi/apicalls/folder_create.c @@ -27,7 +27,7 @@ int mfconn_api_folder_create(mfconn * conn, char *parent, char *name) { - char *api_call; + const char *api_call; int retval; mfhttp *http; @@ -64,7 +64,7 @@ int mfconn_api_folder_create(mfconn * conn, char *parent, char *name) retval = http_get_buf(http, api_call, NULL, NULL); http_destroy(http); - free(api_call); + free((void *)api_call); return retval; } diff --git a/mfapi/apicalls/folder_delete.c b/mfapi/apicalls/folder_delete.c index 241e611..4a29eb4 100644 --- a/mfapi/apicalls/folder_delete.c +++ b/mfapi/apicalls/folder_delete.c @@ -27,7 +27,7 @@ int mfconn_api_folder_delete(mfconn * conn, const char *folderkey) { - char *api_call; + const char *api_call; int retval; mfhttp *http; @@ -48,7 +48,7 @@ int mfconn_api_folder_delete(mfconn * conn, const char *folderkey) retval = http_get_buf(http, api_call, NULL, NULL); http_destroy(http); - free(api_call); + free((void *)api_call); return retval; } diff --git a/mfapi/apicalls/folder_get_content.c b/mfapi/apicalls/folder_get_content.c index 2fb686b..fef52f1 100644 --- a/mfapi/apicalls/folder_get_content.c +++ b/mfapi/apicalls/folder_get_content.c @@ -35,7 +35,7 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *data); long mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr) { - char *api_call; + const char *api_call; int retval; char *content_type; mfhttp *http; @@ -75,7 +75,7 @@ mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr) _decode_folder_get_content_files, NULL); http_destroy(http); - free(api_call); + free((void *)api_call); return retval; } diff --git a/mfapi/apicalls/folder_get_info.c b/mfapi/apicalls/folder_get_info.c index 8f5c00a..e0576da 100644 --- a/mfapi/apicalls/folder_get_info.c +++ b/mfapi/apicalls/folder_get_info.c @@ -33,7 +33,7 @@ static int _decode_folder_get_info(mfhttp * conn, void *data); int mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, char *folderkey) { - char *api_call; + const char *api_call; int retval; mfhttp *http; @@ -59,7 +59,7 @@ mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, char *folderkey) retval = http_get_buf(http, api_call, _decode_folder_get_info, folder); http_destroy(http); - free(api_call); + free((void *)api_call); return retval; } @@ -86,15 +86,15 @@ static int _decode_folder_get_info(mfhttp * conn, void *data) folderkey = json_object_get(node, "folderkey"); if (folderkey != NULL) - folder_set_key(folder, (char *)json_string_value(folderkey)); + folder_set_key(folder, json_string_value(folderkey)); folder_name = json_object_get(node, "name"); if (folder_name != NULL) - folder_set_name(folder, (char *)json_string_value(folder_name)); + folder_set_name(folder, json_string_value(folder_name)); parent_folder = json_object_get(node, "parent_folderkey"); if (parent_folder != NULL) { - folder_set_parent(folder, (char *)json_string_value(parent_folder)); + folder_set_parent(folder, json_string_value(parent_folder)); } // infer that the parent folder must be "myfiles" root if (parent_folder == NULL && folderkey != NULL) diff --git a/mfapi/apicalls/user_get_info.c b/mfapi/apicalls/user_get_info.c index 359114e..e1937a5 100644 --- a/mfapi/apicalls/user_get_info.c +++ b/mfapi/apicalls/user_get_info.c @@ -30,7 +30,7 @@ static int _decode_user_get_info(mfhttp * conn, void *data); int mfconn_api_user_get_info(mfconn * conn) { - char *api_call; + const char *api_call; int retval; mfhttp *http; @@ -46,7 +46,7 @@ int mfconn_api_user_get_info(mfconn * conn) retval = http_get_buf(http, api_call, _decode_user_get_info, NULL); http_destroy(http); - free(api_call); + free((void *)api_call); return retval; } @@ -69,15 +69,15 @@ static int _decode_user_get_info(mfhttp * conn, void *data) email = json_object_get(node, "email"); if (email != NULL) - printf("Email: %s\n\r", (char *)json_string_value(email)); + printf("Email: %s\n\r", json_string_value(email)); first_name = json_object_get(node, "first_name"); if (first_name != NULL) - printf("Name: %s ", (char *)json_string_value(first_name)); + printf("Name: %s ", json_string_value(first_name)); last_name = json_object_get(node, "last_name"); if (node != NULL) - printf("%s", (char *)json_string_value(last_name)); + printf("%s", json_string_value(last_name)); printf("\n\r"); diff --git a/mfapi/apicalls/user_session.c b/mfapi/apicalls/user_session.c index db211a7..a5a7154 100644 --- a/mfapi/apicalls/user_session.c +++ b/mfapi/apicalls/user_session.c @@ -38,15 +38,16 @@ struct user_get_session_token_response { }; int -mfconn_api_user_get_session_token(mfconn * conn, char *server, - char *username, char *password, - int app_id, char *app_key, +mfconn_api_user_get_session_token(mfconn * conn, const char *server, + const char *username, const char *password, + int app_id, const char *app_key, uint32_t * secret_key, - char **secret_time, char **session_token) + char **secret_time, + char **session_token) { char *login_url; char *post_args; - char *user_signature; + const char *user_signature; int retval; struct user_get_session_token_response response; mfhttp *http; @@ -69,7 +70,7 @@ mfconn_api_user_get_session_token(mfconn * conn, char *server, "&token_version=2" "&response_format=json", username, password, user_signature); - free(user_signature); + free((void *)user_signature); http = http_create(); retval = diff --git a/mfapi/file.c b/mfapi/file.c index 7927e67..d36d259 100644 --- a/mfapi/file.c +++ b/mfapi/file.c @@ -217,11 +217,11 @@ const char *file_get_onetime_link(mffile * file) return file->onetime_link; } -ssize_t file_download_direct(mffile * file, char *local_dir) +ssize_t file_download_direct(mffile * file, const char *local_dir) { const char *url; const char *file_name; - char *file_path; + const char *file_path; struct stat file_info; ssize_t bytes_read = 0; int retval; @@ -258,7 +258,7 @@ ssize_t file_download_direct(mffile * file, char *local_dir) memset(&file_info, 0, sizeof(file_info)); retval = stat(file_path, &file_info); - free(file_path); + free((void *)file_path); if (retval != 0) return -1; diff --git a/mfapi/file.h b/mfapi/file.h index 92efce6..b20570c 100644 --- a/mfapi/file.h +++ b/mfapi/file.h @@ -52,6 +52,6 @@ int file_set_onetime_link(mffile * file, const char *onetime_link); const char *file_get_onetime_link(mffile * file); -ssize_t file_download_direct(mffile * file, char *local_dir); +ssize_t file_download_direct(mffile * file, const char *local_dir); #endif diff --git a/mfapi/mfconn.c b/mfapi/mfconn.c index 4069f57..0322604 100644 --- a/mfapi/mfconn.c +++ b/mfapi/mfconn.c @@ -35,8 +35,9 @@ struct mfconn { char *session_token; }; -mfconn *mfconn_create(char *server, char *username, char *password, - int app_id, char *app_key) +mfconn *mfconn_create(const char *server, const char *username, + const char *password, int app_id, + const char *app_key) { mfconn *conn; int retval; @@ -80,9 +81,10 @@ void mfconn_update_secret_key(mfconn * conn) return; } -char *mfconn_create_user_signature(mfconn * conn, char *username, - char *password, int app_id, - char *app_key) +const char *mfconn_create_user_signature(mfconn * conn, + const char *username, + const char *password, int app_id, + const char *app_key) { char *signature_raw; unsigned char signature_enc[20]; // sha1 is 160 bits @@ -108,8 +110,8 @@ char *mfconn_create_user_signature(mfconn * conn, char *username, return strdup((const char *)signature_hex); } -char *mfconn_create_call_signature(mfconn * conn, char *url, - char *args) +const char *mfconn_create_call_signature(mfconn * conn, const char *url, + const char *args) { char *signature_raw; unsigned char signature_enc[16]; // md5 is 128 bits @@ -148,13 +150,14 @@ char *mfconn_create_call_signature(mfconn * conn, char *url, return strdup((const char *)signature_hex); } -char *mfconn_create_signed_get(mfconn * conn, int ssl, char *api, - char *fmt, ...) +const char *mfconn_create_signed_get(mfconn * conn, int ssl, + const char *api, + const char *fmt, ...) { char *api_request = NULL; char *api_args = NULL; char *signature; - char *call_hash; + const char *call_hash; char *session_token; int bytes_to_alloc; int api_args_len; @@ -200,14 +203,14 @@ char *mfconn_create_signed_get(mfconn * conn, int ssl, char *api, // correct user error of trailing slash if (api[api_len - 1] == '/') - api[api_len - 1] = '\0'; + return NULL; api_request = strdup_printf("%s//%s/api/%s", (ssl ? "https:" : "http:"), conn->server, api); call_hash = mfconn_create_call_signature(conn, api_request, api_args); signature = strdup_printf("&signature=%s", call_hash); - free(call_hash); + free((void *)call_hash); // compute the amount of space requred to realloc() the request bytes_to_alloc = api_args_len; diff --git a/mfapi/mfconn.h b/mfapi/mfconn.h index 4ac9eac..7d2b4d2 100644 --- a/mfapi/mfconn.h +++ b/mfapi/mfconn.h @@ -26,19 +26,22 @@ typedef struct mfconn mfconn; -mfconn *mfconn_create(char *server, char *username, char *password, - int app_id, char *app_key); +mfconn *mfconn_create(const char *server, const char *username, + const char *password, int app_id, + const char *app_key); void mfconn_destroy(mfconn * conn); -ssize_t mfconn_download_direct(mffile * file, char *local_dir); +ssize_t mfconn_download_direct(mffile * file, const char *local_dir); -char *mfconn_create_signed_get(mfconn * conn, int ssl, char *api, - char *fmt, ...); +const char *mfconn_create_signed_get(mfconn * conn, int ssl, + const char *api, const char *fmt, + ...); -char *mfconn_create_user_signature(mfconn * conn, char *username, - char *password, int app_id, - char *app_key); +const char *mfconn_create_user_signature(mfconn * conn, + const char *username, + const char *password, int app_id, + const char *app_key); void mfconn_update_secret_key(mfconn * conn); diff --git a/mfshell/commands.h b/mfshell/commands.h index ef3c868..5c96aef 100644 --- a/mfshell/commands.h +++ b/mfshell/commands.h @@ -22,36 +22,52 @@ #include "mfshell.h" -int mfshell_cmd_help(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_help(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_debug(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_debug(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_host(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_host(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_auth(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_auth(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_whomai(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_whomai(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_list(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_list(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_chdir(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_chdir(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_pwd(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_pwd(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_lpwd(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_lpwd(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_lcd(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_lcd(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_file(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_file(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_links(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_links(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_mkdir(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_get(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_get(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_whoami(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_whoami(mfshell * mfshell, int argc, + char *const argv[]); -int mfshell_cmd_rmdir(mfshell * mfshell, int argc, char **argv); +int mfshell_cmd_rmdir(mfshell * mfshell, int argc, + char *const argv[]); #endif diff --git a/mfshell/commands/auth.c b/mfshell/commands/auth.c index dff8b71..2d02286 100644 --- a/mfshell/commands/auth.c +++ b/mfshell/commands/auth.c @@ -32,7 +32,7 @@ static char *_get_login_from_user(void); static char *_get_passwd_from_user(void); -int mfshell_cmd_auth(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_auth(mfshell * mfshell, int argc, char *const argv[]) { char *username; char *password; diff --git a/mfshell/commands/chdir.c b/mfshell/commands/chdir.c index 1aa8ebf..b6e96fd 100644 --- a/mfshell/commands/chdir.c +++ b/mfshell/commands/chdir.c @@ -26,7 +26,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_chdir(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_chdir(mfshell * mfshell, int argc, char *const argv[]) { mffolder *folder_new; const char *folder_curr; diff --git a/mfshell/commands/debug.c b/mfshell/commands/debug.c index 1b58855..96d116b 100644 --- a/mfshell/commands/debug.c +++ b/mfshell/commands/debug.c @@ -25,7 +25,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_debug(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_debug(mfshell * mfshell, int argc, char *const argv[]) { (void)argv; if (argc != 1) { diff --git a/mfshell/commands/file.c b/mfshell/commands/file.c index c2d3924..d57318e 100644 --- a/mfshell/commands/file.c +++ b/mfshell/commands/file.c @@ -26,7 +26,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_file(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_file(mfshell * mfshell, int argc, char *const argv[]) { mffile *file; int len; diff --git a/mfshell/commands/get.c b/mfshell/commands/get.c index c9da178..afa4b3d 100644 --- a/mfshell/commands/get.c +++ b/mfshell/commands/get.c @@ -29,7 +29,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_get(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_get(mfshell * mfshell, int argc, char *const argv[]) { mffile *file; int len; diff --git a/mfshell/commands/help.c b/mfshell/commands/help.c index 911b52b..14bd134 100644 --- a/mfshell/commands/help.c +++ b/mfshell/commands/help.c @@ -23,7 +23,7 @@ #include "../mfshell.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_help(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_help(mfshell * mfshell, int argc, char *const argv[]) { (void)argv; unsigned int column1_width = 0; diff --git a/mfshell/commands/host.c b/mfshell/commands/host.c index 53f19c7..def5544 100644 --- a/mfshell/commands/host.c +++ b/mfshell/commands/host.c @@ -28,7 +28,7 @@ static char *_get_host_from_user(void); -int mfshell_cmd_host(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_host(mfshell * mfshell, int argc, char *const argv[]) { char *alt_host = NULL; char *host; diff --git a/mfshell/commands/lcd.c b/mfshell/commands/lcd.c index 79c3056..270e44d 100644 --- a/mfshell/commands/lcd.c +++ b/mfshell/commands/lcd.c @@ -25,7 +25,7 @@ #include "../mfshell.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_lcd(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_lcd(mfshell * mfshell, int argc, char *const argv[]) { int retval; const char *dir; diff --git a/mfshell/commands/links.c b/mfshell/commands/links.c index 90659ac..a32ec17 100644 --- a/mfshell/commands/links.c +++ b/mfshell/commands/links.c @@ -26,7 +26,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_links(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_links(mfshell * mfshell, int argc, char *const argv[]) { mffile *file; int len; diff --git a/mfshell/commands/list.c b/mfshell/commands/list.c index bdccdb2..1949bc7 100644 --- a/mfshell/commands/list.c +++ b/mfshell/commands/list.c @@ -25,7 +25,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_list(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[]) { (void)argv; int retval; diff --git a/mfshell/commands/lpwd.c b/mfshell/commands/lpwd.c index d97d88e..769ef4e 100644 --- a/mfshell/commands/lpwd.c +++ b/mfshell/commands/lpwd.c @@ -25,7 +25,7 @@ #include "../mfshell.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_lpwd(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_lpwd(mfshell * mfshell, int argc, char *const argv[]) { (void)argv; if (mfshell == NULL) diff --git a/mfshell/commands/mkdir.c b/mfshell/commands/mkdir.c index e573e37..0c57868 100644 --- a/mfshell/commands/mkdir.c +++ b/mfshell/commands/mkdir.c @@ -25,7 +25,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char *const argv[]) { int retval; const char *folder_curr; diff --git a/mfshell/commands/pwd.c b/mfshell/commands/pwd.c index a05c272..9bc72aa 100644 --- a/mfshell/commands/pwd.c +++ b/mfshell/commands/pwd.c @@ -25,7 +25,7 @@ #include "../../mfapi/folder.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_pwd(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_pwd(mfshell * mfshell, int argc, char *const argv[]) { (void)argv; const char *folder_name; diff --git a/mfshell/commands/rmdir.c b/mfshell/commands/rmdir.c index 36cda8a..c616ee3 100644 --- a/mfshell/commands/rmdir.c +++ b/mfshell/commands/rmdir.c @@ -25,7 +25,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_rmdir(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_rmdir(mfshell * mfshell, int argc, char *const argv[]) { int retval; const char *folderkey; diff --git a/mfshell/commands/whoami.c b/mfshell/commands/whoami.c index 25e1933..6e6f3e4 100644 --- a/mfshell/commands/whoami.c +++ b/mfshell/commands/whoami.c @@ -24,7 +24,7 @@ #include "../../mfapi/mfconn.h" #include "../commands.h" // IWYU pragma: keep -int mfshell_cmd_whoami(mfshell * mfshell, int argc, char **argv) +int mfshell_cmd_whoami(mfshell * mfshell, int argc, char *const argv[]) { (void)argv; int retval; diff --git a/mfshell/main.c b/mfshell/main.c index 86dc771..fccf445 100644 --- a/mfshell/main.c +++ b/mfshell/main.c @@ -31,7 +31,7 @@ static void mfshell_run(mfshell * shell); static void mfshell_parse_commands(mfshell * shell, char *command); -void print_help(char *cmd) +void print_help(const char *cmd) { fprintf(stderr, "A shell to access a MediaFire account.\n"); fprintf(stderr, "\n"); @@ -61,7 +61,7 @@ void print_help(char *cmd) } void -parse_argv(int argc, char **argv, char **username, +parse_argv(int argc, char *const argv[], char **username, char **password, char **server, char **command) { static struct option long_options[] = { @@ -117,7 +117,7 @@ parse_argv(int argc, char **argv, char **username, } } -int main(int argc, char **argv) +int main(int argc, char *const argv[]) { mfshell *shell; char *server = "www.mediafire.com"; diff --git a/mfshell/mfshell.c b/mfshell/mfshell.c index 69190b6..a470dd9 100644 --- a/mfshell/mfshell.c +++ b/mfshell/mfshell.c @@ -85,7 +85,7 @@ mfshell *mfshell_create(int app_id, char *app_key, char *server) return shell; } -int mfshell_exec(mfshell * shell, int argc, char **argv) +int mfshell_exec(mfshell * shell, int argc, char *const argv[]) { mfcmd *curr_cmd; diff --git a/mfshell/mfshell.h b/mfshell/mfshell.h index a7f7701..9eef575 100644 --- a/mfshell/mfshell.h +++ b/mfshell/mfshell.h @@ -33,7 +33,7 @@ struct mfcmd { char *name; char *argstring; char *help; - int (*handler) (mfshell * mfshell, int argc, char **argv); + int (*handler) (mfshell * mfshell, int argc, char *const argv[]); }; struct mfshell { @@ -57,7 +57,7 @@ mfshell *mfshell_create(int app_id, char *app_key, char *server); int mfshell_authenticate_user(mfshell * mfshell); -int mfshell_exec(mfshell * mfshell, int argc, char **argv); +int mfshell_exec(mfshell * mfshell, int argc, char *const argv[]); int mfshell_exec_shell_command(mfshell * mfshell, char *command); diff --git a/tests/valgrind.sh b/tests/valgrind.sh index 44d20c9..df46617 100755 --- a/tests/valgrind.sh +++ b/tests/valgrind.sh @@ -17,4 +17,4 @@ esac cmd="valgrind --suppressions="${source_dir}/valgrind.supp" --fullpath-after="$source_dir" --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes" -$cmd "${binary_dir}/mfshell" -c "help; whoami" +$cmd "${binary_dir}/mediafire-shell" -c "help; whoami"