@@ -58,7 +58,7 @@ typedef struct {
5858 * may be NULL. The cache makes it easy to load this and check
5959 * if it has been modified since the last load and/or write.
6060 */
61- int git_sortedcache_new (
61+ GIT_WARN_UNUSED_RESULT int git_sortedcache_new (
6262 git_sortedcache * * out ,
6363 size_t item_path_offset , /* use offsetof(struct, path-field) macro */
6464 git_sortedcache_free_item_fn free_item ,
@@ -71,7 +71,7 @@ int git_sortedcache_new(
7171 * - `copy_item` can be NULL to just use memcpy
7272 * - if `lock`, grabs read lock on `src` during copy and releases after
7373 */
74- int git_sortedcache_copy (
74+ GIT_WARN_UNUSED_RESULT int git_sortedcache_copy (
7575 git_sortedcache * * out ,
7676 git_sortedcache * src ,
7777 bool lock ,
@@ -88,7 +88,7 @@ void git_sortedcache_free(git_sortedcache *sc);
8888void git_sortedcache_incref (git_sortedcache * sc );
8989
9090/* Get the pathname associated with this cache at creation time */
91- const char * git_sortedcache_path (git_sortedcache * sc );
91+ GIT_WARN_UNUSED_RESULT const char * git_sortedcache_path (git_sortedcache * sc );
9292
9393/*
9494 * CACHE WRITE FUNCTIONS
@@ -100,7 +100,7 @@ const char *git_sortedcache_path(git_sortedcache *sc);
100100 */
101101
102102/* Lock sortedcache for write */
103- int git_sortedcache_wlock (git_sortedcache * sc );
103+ GIT_WARN_UNUSED_RESULT int git_sortedcache_wlock (git_sortedcache * sc );
104104
105105/* Unlock sorted cache when done with write */
106106void git_sortedcache_wunlock (git_sortedcache * sc );
@@ -120,7 +120,8 @@ void git_sortedcache_wunlock(git_sortedcache *sc);
120120 *
121121 * @return 0 if up-to-date, 1 if out-of-date, <0 on error
122122 */
123- int git_sortedcache_lockandload (git_sortedcache * sc , git_buf * buf );
123+ GIT_WARN_UNUSED_RESULT int git_sortedcache_lockandload (
124+ git_sortedcache * sc , git_buf * buf );
124125
125126/* Refresh file timestamp after write completes
126127 * You should already be holding the write lock when you call this.
@@ -137,13 +138,13 @@ int git_sortedcache_clear(git_sortedcache *sc, bool wlock);
137138/* Find and/or insert item, returning pointer to item data.
138139 * You should already be holding the write lock when you call this.
139140 */
140- int git_sortedcache_upsert (
141+ GIT_WARN_UNUSED_RESULT int git_sortedcache_upsert (
141142 void * * out , git_sortedcache * sc , const char * key );
142143
143144/* Removes entry at pos from cache
144145 * You should already be holding the write lock when you call this.
145146 */
146- int git_sortedcache_remove (git_sortedcache * sc , size_t pos );
147+ GIT_WARN_UNUSED_RESULT int git_sortedcache_remove (git_sortedcache * sc , size_t pos );
147148
148149/*
149150 * CACHE READ FUNCTIONS
@@ -155,26 +156,29 @@ int git_sortedcache_remove(git_sortedcache *sc, size_t pos);
155156 */
156157
157158/* Lock sortedcache for read */
158- int git_sortedcache_rlock (git_sortedcache * sc );
159+ GIT_WARN_UNUSED_RESULT int git_sortedcache_rlock (git_sortedcache * sc );
159160
160161/* Unlock sorted cache when done with read */
161162void git_sortedcache_runlock (git_sortedcache * sc );
162163
163164/* Lookup item by key - returns NULL if not found */
164- void * git_sortedcache_lookup (const git_sortedcache * sc , const char * key );
165+ GIT_WARN_UNUSED_RESULT void * git_sortedcache_lookup (
166+ const git_sortedcache * sc , const char * key );
165167
166168/* Get how many items are in the cache
167169 *
168170 * You can call this function without holding a lock, but be aware
169171 * that it may change before you use it.
170172 */
171- size_t git_sortedcache_entrycount (const git_sortedcache * sc );
173+ GIT_WARN_UNUSED_RESULT size_t git_sortedcache_entrycount (
174+ const git_sortedcache * sc );
172175
173176/* Lookup item by index - returns NULL if out of range */
174- void * git_sortedcache_entry (git_sortedcache * sc , size_t pos );
177+ GIT_WARN_UNUSED_RESULT void * git_sortedcache_entry (
178+ git_sortedcache * sc , size_t pos );
175179
176180/* Lookup index of item by key - returns GIT_ENOTFOUND if not found */
177- int git_sortedcache_lookup_index (
181+ GIT_WARN_UNUSED_RESULT int git_sortedcache_lookup_index (
178182 size_t * out , git_sortedcache * sc , const char * key );
179183
180184#endif
0 commit comments