check whether a connection exists before executing certain commands

This commit is contained in:
josch
2014-10-25 11:34:34 +02:00
parent 5e24f47c10
commit fe17cb517f
11 changed files with 78 additions and 3 deletions

View File

@@ -38,6 +38,11 @@ int mfshell_cmd_changes(mfshell * mfshell, int argc, char *const argv[])
if (mfshell == NULL)
return -1;
if (mfshell->conn == NULL) {
fprintf(stderr, "conn is NULL\n");
return -1;
}
switch (argc) {
case 1:
revision = 0;
@@ -54,6 +59,11 @@ int mfshell_cmd_changes(mfshell * mfshell, int argc, char *const argv[])
retval = mfconn_api_device_get_changes(mfshell->conn, revision, &changes);
mfconn_update_secret_key(mfshell->conn);
if (retval != 0) {
fprintf(stderr, "mfconn_api_device_get_changes failed\n");
return -1;
}
for (i = 0; changes[i].change != MFCONN_DEVICE_CHANGE_END; i++) {
switch (changes[i].change) {
case MFCONN_DEVICE_CHANGE_DELETED_FOLDER: