diff --git a/common/commit-mgr.c b/common/commit-mgr.c index 32766ca8b..7ecde9cb7 100644 --- a/common/commit-mgr.c +++ b/common/commit-mgr.c @@ -141,10 +141,7 @@ seaf_commit_from_data (const char *id, char *data, gsize len) object = json_loadb (data, len, 0, &jerror); if (!object) { - if (jerror.text) - seaf_warning ("Failed to load commit json: %s.\n", jerror.text); - else - seaf_warning ("Failed to load commit json.\n"); + seaf_warning ("Failed to load commit json: %s.\n", jerror.text); return NULL; } } @@ -821,10 +818,7 @@ load_commit (SeafCommitManager *mgr, object = json_loadb (data, len, 0, &jerror); if (!object) { - if (jerror.text) - seaf_warning ("Failed to load commit json object: %s.\n", jerror.text); - else - seaf_warning ("Failed to load commit json object.\n"); + seaf_warning ("Failed to load commit json object: %s.\n", jerror.text); goto out; } } diff --git a/common/fs-mgr.c b/common/fs-mgr.c index 8a72c93d2..777dd265e 100644 --- a/common/fs-mgr.c +++ b/common/fs-mgr.c @@ -1042,10 +1042,7 @@ seafile_from_json (const char *id, void *data, int len) object = json_loadb ((const char *)decompressed, outlen, 0, &error); g_free (decompressed); if (!object) { - if (error.text) - seaf_warning ("Failed to load seafile json object: %s.\n", error.text); - else - seaf_warning ("Failed to load seafile json object.\n"); + seaf_warning ("Failed to load seafile json object: %s.\n", error.text); return NULL; } @@ -1515,10 +1512,7 @@ seaf_dir_from_json (const char *dir_id, uint8_t *data, int len) object = json_loadb ((const char *)decompressed, outlen, 0, &error); g_free (decompressed); if (!object) { - if (error.text) - seaf_warning ("Failed to load seafdir json object: %s.\n", error.text); - else - seaf_warning ("Failed to load seafdir json object.\n"); + seaf_warning ("Failed to load seafdir json object: %s.\n", error.text); return NULL; } @@ -1807,10 +1801,7 @@ parse_metadata_type_json (const char *obj_id, uint8_t *data, int len) object = json_loadb ((const char *)decompressed, outlen, 0, &error); g_free (decompressed); if (!object) { - if (error.text) - seaf_warning ("Failed to load fs json object: %s.\n", error.text); - else - seaf_warning ("Failed to load fs json object.\n"); + seaf_warning ("Failed to load fs json object: %s.\n", error.text); return SEAF_METADATA_TYPE_INVALID; } @@ -1863,10 +1854,7 @@ fs_object_from_json (const char *obj_id, uint8_t *data, int len) object = json_loadb ((const char *)decompressed, outlen, 0, &error); g_free (decompressed); if (!object) { - if (error.text) - seaf_warning ("Failed to load fs json object: %s.\n", error.text); - else - seaf_warning ("Failed to load fs json object.\n"); + seaf_warning ("Failed to load fs json object: %s.\n", error.text); return NULL; } diff --git a/common/index/index.c b/common/index/index.c index f4d9d7a44..31f338442 100644 --- a/common/index/index.c +++ b/common/index/index.c @@ -98,20 +98,6 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size) return 0; } -static inline size_t estimate_cache_size(size_t ondisk_size, unsigned int entries) -{ - long per_entry; - - per_entry = sizeof(struct cache_entry) - sizeof(struct ondisk_cache_entry); - - /* - * Alignment can cause differences. This should be "alignof", but - * since that's a gcc'ism, just use the size of a pointer. - */ - per_entry += sizeof(void *); - return ondisk_size + entries*per_entry; -} - static int convert_from_disk(struct ondisk_cache_entry *ondisk, struct cache_entry **ce) { size_t len; @@ -478,20 +464,6 @@ void mark_all_ce_unused(struct index_state *index) } -static int is_empty_blob_sha1(const unsigned char *sha1) -{ - /* static const unsigned char empty_blob_sha1[20] = { */ - /* 0xe6,0x9d,0xe2,0x9b,0xb2,0xd1,0xd6,0x43,0x4b,0x8b, */ - /* 0x29,0xae,0x77,0x5a,0xd8,0xc2,0xe4,0x8c,0x53,0x91 */ - /* }; */ - - static const unsigned char empty_blob_sha1[20] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - return !hashcmp(sha1, empty_blob_sha1); -} - static int ce_match_stat_basic(struct cache_entry *ce, SeafStat *st) { unsigned int changed = 0; @@ -1949,38 +1921,6 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce) } #endif -static int ce_write_entry(WriteIndexInfo *info, int fd, struct cache_entry *ce) -{ - int size = ondisk_ce_size(ce); - struct ondisk_cache_entry *ondisk = calloc(1, size); - char *name; - int result; - - ondisk->ctime.sec = htonl((unsigned int)ce->ce_ctime.sec); - ondisk->mtime.sec = htonl((unsigned int)ce->ce_mtime.sec); - ondisk->dev = htonl(ce->ce_dev); - ondisk->ino = htonl(ce->ce_ino); - ondisk->mode = htonl(ce->ce_mode); - ondisk->uid = htonl(ce->ce_uid); - ondisk->gid = htonl(ce->ce_gid); - ondisk->size = hton64(ce->ce_size); - hashcpy(ondisk->sha1, ce->sha1); - ondisk->flags = htons(ce->ce_flags); - /* if (ce->ce_flags & CE_EXTENDED) { */ - /* struct ondisk_cache_entry_extended *ondisk2; */ - /* ondisk2 = (struct ondisk_cache_entry_extended *)ondisk; */ - /* ondisk2->flags2 = htons((ce->ce_flags & CE_EXTENDED_FLAGS) >> 16); */ - /* name = ondisk2->name; */ - /* } */ - /* else */ - name = ondisk->name; - memcpy(name, ce->name, ce_namelen(ce)); - - result = ce_write(info, fd, ondisk, size); - free(ondisk); - return result; -} - static int ce_write_entry2(WriteIndexInfo *info, int fd, struct cache_entry *ce) { int size = ondisk_ce_size2(ce); diff --git a/daemon/clone-mgr.c b/daemon/clone-mgr.c index aaca3c7e9..7d8497f55 100644 --- a/daemon/clone-mgr.c +++ b/daemon/clone-mgr.c @@ -554,11 +554,7 @@ load_more_info_cb (sqlite3_stmt *stmt, void *data) more_info = (const char *)sqlite3_column_text (stmt, 0); object = json_loads (more_info, 0, &jerror); if (!object) { - if (jerror.text) - seaf_warning ("Failed to load more sync info from json: %s.\n", jerror.text); - else - seaf_warning ("Failed to load more sync info from json.\n"); - + seaf_warning ("Failed to load more sync info from json: %s.\n", jerror.text); return FALSE; } @@ -1323,11 +1319,7 @@ add_task_common (SeafCloneManager *mgr, object = json_loads (more_info, 0, &jerror); if (!object) { - if (jerror.text) - seaf_warning ("Failed to load more sync info from json: %s.\n", jerror.text); - else - seaf_warning ("Failed to load more sync info from json.\n"); - + seaf_warning ("Failed to load more sync info from json: %s.\n", jerror.text); clone_task_free (task); return NULL; } diff --git a/daemon/merge-recursive.c b/daemon/merge-recursive.c index 44263fc69..caf082433 100644 --- a/daemon/merge-recursive.c +++ b/daemon/merge-recursive.c @@ -381,38 +381,6 @@ static int remove_file(struct merge_options *o, int clean, return 0; } -inline static int file_exists(const char *f) -{ - SeafStat sb; - return (seaf_stat (f, &sb) == 0); -} - -#if 0 -static int would_lose_untracked(struct index_state *index, const char *path, const char *real_path) -{ - int pos = index_name_pos(index, path, strlen(path)); - - if (pos < 0) - pos = -1 - pos; - while (pos < index->cache_nr && - !strcmp(path, index->cache[pos]->name)) { - /* - * If stage #0, it is definitely tracked. - * If it has stage #2 then it was tracked - * before this merge started. All other - * cases the path was not tracked. - */ - switch (ce_stage(index->cache[pos])) { - case 0: - case 2: - return 0; - } - pos++; - } - return file_exists(real_path); -} -#endif - static int create_leading_directories(int base_len, const char *path, char **new_path, const char *conflict_suffix, diff --git a/daemon/processors/sendfs-v2-proc.c b/daemon/processors/sendfs-v2-proc.c index 8228df1f6..3a8aa1d46 100644 --- a/daemon/processors/sendfs-v2-proc.c +++ b/daemon/processors/sendfs-v2-proc.c @@ -200,6 +200,7 @@ calculate_send_object_list (void *vdata) TransferTask *task = proc->tx_task; SeafBranch *local = NULL, *master = NULL; + SeafCommit *local_head = NULL, *master_head = NULL; local = seaf_branch_manager_get_branch (seaf->branch_mgr, task->repo_id, "local"); if (!local) { seaf_warning ("Branch local not found for repo %.8s.\n", task->repo_id); @@ -213,7 +214,6 @@ calculate_send_object_list (void *vdata) goto out; } - SeafCommit *local_head = NULL, *master_head = NULL; local_head = seaf_commit_manager_get_commit (seaf->commit_mgr, task->repo_id, task->repo_version, local->commit_id); diff --git a/daemon/repo-mgr.c b/daemon/repo-mgr.c index dc6a7b700..3a9817864 100644 --- a/daemon/repo-mgr.c +++ b/daemon/repo-mgr.c @@ -1084,6 +1084,7 @@ seaf_repo_manager_is_ignored_hidden_file (const char *filename) return FALSE; } +#ifdef WIN32 static inline gboolean has_trailing_space_or_period (const char *path) { @@ -1094,6 +1095,7 @@ has_trailing_space_or_period (const char *path) return FALSE; } +#endif typedef enum IgnoreReason { IGNORE_REASON_END_SPACE_PERIOD = 0, @@ -2139,8 +2141,6 @@ add_path_to_index (SeafRepo *repo, struct index_state *istate, GList **scanned_dirs, gint64 *total_size, GQueue **remain_files, LockedFileSet *fset) { - SeafStat st; - /* If we've recursively scanned the parent directory, don't need to scan * any files under it any more. */ @@ -4167,13 +4167,6 @@ print_index (struct index_state *istate) } #endif -static inline void -print_time (const char *desc, GTimeVal *s, GTimeVal *e) -{ - seaf_message ("%s: %lu\n", desc, - (e->tv_sec*G_USEC_PER_SEC+e->tv_usec - (s->tv_sec*G_USEC_PER_SEC+s->tv_usec))/1000); -} - char * seaf_repo_index_commit (SeafRepo *repo, const char *desc, gboolean is_force_commit, @@ -7485,18 +7478,6 @@ save_repo_property (SeafRepoManager *manager, pthread_mutex_unlock (&manager->priv->db_lock); } -inline static gboolean is_peer_relay (const char *peer_id) -{ - CcnetPeer *peer = ccnet_get_peer(seaf->ccnetrpc_client, peer_id); - - if (!peer) - return FALSE; - - gboolean is_relay = string_list_is_exists(peer->role_list, "MyRelay"); - g_object_unref (peer); - return is_relay; -} - int seaf_repo_manager_set_repo_relay_id (SeafRepoManager *mgr, SeafRepo *repo, diff --git a/daemon/sync-mgr.c b/daemon/sync-mgr.c index ce1e4087e..ffd500db4 100644 --- a/daemon/sync-mgr.c +++ b/daemon/sync-mgr.c @@ -3331,8 +3331,10 @@ seaf_sync_manager_get_path_sync_status (SeafSyncManager *mgr, /* If the repo is in error, all files in it should show no sync status. */ sync_info = get_sync_info (mgr, repo_id); - if (sync_info && sync_info->in_error) - return SYNC_STATUS_NONE; + if (sync_info && sync_info->in_error) { + ret = SYNC_STATUS_NONE; + goto out; + } pthread_mutex_lock (&mgr->priv->paths_lock); diff --git a/daemon/transfer-mgr.c b/daemon/transfer-mgr.c index 60069de53..cc49fd554 100644 --- a/daemon/transfer-mgr.c +++ b/daemon/transfer-mgr.c @@ -406,18 +406,6 @@ transfer_task_with_proc_failure (TransferTask *task, } } -inline static gboolean is_peer_relay (const char *peer_id) -{ - CcnetPeer *peer = ccnet_get_peer(seaf->ccnetrpc_client, peer_id); - - if (!peer) - return FALSE; - - gboolean is_relay = string_list_is_exists(peer->role_list, "MyRelay"); - g_object_unref (peer); - return is_relay; -} - /* * Transfer Manager. */ diff --git a/daemon/wt-monitor-macos.c b/daemon/wt-monitor-macos.c index c5e4d7851..195e696f0 100644 --- a/daemon/wt-monitor-macos.c +++ b/daemon/wt-monitor-macos.c @@ -236,11 +236,9 @@ stream_callback (ConstFSEventStreamRef streamRef, const FSEventStreamEventId eventIds[]) { RepoWatchInfo *info; - char *repo_id; SeafWTMonitor *monitor = (SeafWTMonitor *)clientCallBackInfo; SeafWTMonitorPriv *priv = monitor->priv; char **paths = (char **)eventPaths; - char *dir; info = g_hash_table_lookup (priv->info_hash, (gpointer)(long)streamRef); if (!info) {