@@ -210,7 +210,8 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
210210 const git_remote_create_options dummy_opts = GIT_REMOTE_CREATE_OPTIONS_INIT ;
211211 int error = -1 ;
212212
213- assert (out && url );
213+ GIT_ASSERT_ARG (out );
214+ GIT_ASSERT_ARG (url );
214215
215216 if (!opts ) {
216217 opts = & dummy_opts ;
@@ -459,7 +460,9 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
459460 struct refspec_cb_data data = { NULL };
460461 bool optional_setting_found = false, found ;
461462
462- assert (out && repo && name );
463+ GIT_ASSERT_ARG (out );
464+ GIT_ASSERT_ARG (repo );
465+ GIT_ASSERT_ARG (name );
463466
464467 if ((error = ensure_remote_name_is_valid (name )) < 0 )
465468 return error ;
@@ -581,19 +584,19 @@ static int lookup_remote_prune_config(git_remote *remote, git_config *config, co
581584
582585const char * git_remote_name (const git_remote * remote )
583586{
584- assert (remote );
587+ GIT_ASSERT_ARG_WITH_RETVAL (remote , NULL );
585588 return remote -> name ;
586589}
587590
588591git_repository * git_remote_owner (const git_remote * remote )
589592{
590- assert (remote );
593+ GIT_ASSERT_ARG_WITH_RETVAL (remote , NULL );
591594 return remote -> repo ;
592595}
593596
594597const char * git_remote_url (const git_remote * remote )
595598{
596- assert (remote );
599+ GIT_ASSERT_ARG_WITH_RETVAL (remote , NULL );
597600 return remote -> url ;
598601}
599602
@@ -603,7 +606,8 @@ static int set_url(git_repository *repo, const char *remote, const char *pattern
603606 git_buf buf = GIT_BUF_INIT , canonical_url = GIT_BUF_INIT ;
604607 int error ;
605608
606- assert (repo && remote );
609+ GIT_ASSERT_ARG (repo );
610+ GIT_ASSERT_ARG (remote );
607611
608612 if ((error = ensure_remote_name_is_valid (remote )) < 0 )
609613 return error ;
@@ -637,7 +641,7 @@ int git_remote_set_url(git_repository *repo, const char *remote, const char *url
637641
638642const char * git_remote_pushurl (const git_remote * remote )
639643{
640- assert (remote );
644+ GIT_ASSERT_ARG_WITH_RETVAL (remote , NULL );
641645 return remote -> pushurl ;
642646}
643647
@@ -670,8 +674,8 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int
670674{
671675 const char * url = NULL ;
672676
673- assert (remote );
674- assert (direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH );
677+ GIT_ASSERT_ARG (remote );
678+ GIT_ASSERT_ARG (direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH );
675679
676680 if (direction == GIT_DIRECTION_FETCH ) {
677681 url = remote -> url ;
@@ -716,7 +720,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
716720 git_credential_acquire_cb credentials = NULL ;
717721 git_transport_cb transport = NULL ;
718722
719- assert (remote );
723+ GIT_ASSERT_ARG (remote );
720724
721725 if (callbacks ) {
722726 GIT_ERROR_CHECK_VERSION (callbacks , GIT_REMOTE_CALLBACKS_VERSION , "git_remote_callbacks" );
@@ -781,7 +785,7 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
781785
782786int git_remote_ls (const git_remote_head * * * out , size_t * size , git_remote * remote )
783787{
784- assert (remote );
788+ GIT_ASSERT_ARG (remote );
785789
786790 if (!remote -> transport ) {
787791 git_error_set (GIT_ERROR_NET , "this remote has never connected" );
@@ -798,7 +802,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
798802 git_buf val = GIT_BUF_INIT ;
799803 int error ;
800804
801- assert (remote );
805+ GIT_ASSERT_ARG (remote );
802806
803807 if (!proxy_url || !remote -> repo )
804808 return -1 ;
@@ -927,7 +931,7 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
927931 const git_strarray * custom_headers = NULL ;
928932 const git_proxy_options * proxy = NULL ;
929933
930- assert (remote );
934+ GIT_ASSERT_ARG (remote );
931935
932936 if (!remote -> repo ) {
933937 git_error_set (GIT_ERROR_INVALID , "cannot download detached remote" );
@@ -1066,7 +1070,8 @@ static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *upda
10661070 unsigned int i ;
10671071 git_remote_head * remote_ref ;
10681072
1069- assert (update_heads && fetchspec_src );
1073+ GIT_ASSERT_ARG (update_heads );
1074+ GIT_ASSERT_ARG (fetchspec_src );
10701075
10711076 * out = NULL ;
10721077
@@ -1120,7 +1125,9 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
11201125 const char * ref_name ;
11211126 int error = 0 , update ;
11221127
1123- assert (out && spec && ref );
1128+ GIT_ASSERT_ARG (out );
1129+ GIT_ASSERT_ARG (spec );
1130+ GIT_ASSERT_ARG (ref );
11241131
11251132 * out = NULL ;
11261133
@@ -1157,7 +1164,7 @@ static int git_remote_write_fetchhead(git_remote *remote, git_refspec *spec, git
11571164 unsigned int i = 0 ;
11581165 int error = 0 ;
11591166
1160- assert (remote );
1167+ GIT_ASSERT_ARG (remote );
11611168
11621169 /* no heads, nothing to do */
11631170 if (update_heads -> length == 0 )
@@ -1373,7 +1380,7 @@ static int update_tips_for_spec(
13731380 git_refspec tagspec ;
13741381 git_vector update_heads ;
13751382
1376- assert (remote );
1383+ GIT_ASSERT_ARG (remote );
13771384
13781385 if (git_repository_odb__weakptr (& odb , remote -> repo ) < 0 )
13791386 return -1 ;
@@ -1677,7 +1684,7 @@ int git_remote_update_tips(
16771684
16781685int git_remote_connected (const git_remote * remote )
16791686{
1680- assert (remote );
1687+ GIT_ASSERT_ARG (remote );
16811688
16821689 if (!remote -> transport || !remote -> transport -> is_connected )
16831690 return 0 ;
@@ -1688,7 +1695,7 @@ int git_remote_connected(const git_remote *remote)
16881695
16891696int git_remote_stop (git_remote * remote )
16901697{
1691- assert (remote );
1698+ GIT_ASSERT_ARG (remote );
16921699
16931700 if (remote -> transport && remote -> transport -> cancel )
16941701 remote -> transport -> cancel (remote -> transport );
@@ -1698,7 +1705,7 @@ int git_remote_stop(git_remote *remote)
16981705
16991706int git_remote_disconnect (git_remote * remote )
17001707{
1701- assert (remote );
1708+ GIT_ASSERT_ARG (remote );
17021709
17031710 if (git_remote_connected (remote ))
17041711 remote -> transport -> close (remote -> transport );
@@ -1784,7 +1791,7 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
17841791
17851792const git_indexer_progress * git_remote_stats (git_remote * remote )
17861793{
1787- assert (remote );
1794+ GIT_ASSERT_ARG_WITH_RETVAL (remote , NULL );
17881795 return & remote -> stats ;
17891796}
17901797
@@ -1799,7 +1806,7 @@ int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_
17991806 git_config * config ;
18001807 int error ;
18011808
1802- assert (repo && remote );
1809+ GIT_ASSERT_ARG (repo && remote );
18031810
18041811 if ((error = ensure_remote_name_is_valid (remote )) < 0 )
18051812 return error ;
@@ -2063,7 +2070,7 @@ int git_remote_rename(git_strarray *out, git_repository *repo, const char *name,
20632070 git_vector problem_refspecs = GIT_VECTOR_INIT ;
20642071 git_remote * remote = NULL ;
20652072
2066- assert (out && repo && name && new_name );
2073+ GIT_ASSERT_ARG (out && repo && name && new_name );
20672074
20682075 if ((error = git_remote_lookup (& remote , repo , name )) < 0 )
20692076 return error ;
@@ -2239,7 +2246,7 @@ static const char *name_offset(size_t *len_out, const char *name)
22392246 prefix_len = strlen ("remote." );
22402247 dot = strchr (name + prefix_len , '.' );
22412248
2242- assert (dot );
2249+ GIT_ASSERT_ARG_WITH_RETVAL (dot , NULL );
22432250
22442251 * len_out = dot - name - prefix_len ;
22452252 return name + prefix_len ;
@@ -2269,10 +2276,13 @@ static int remove_branch_config_related_entries(
22692276 if (strcmp (remote_name , entry -> value ))
22702277 continue ;
22712278
2272- branch = name_offset (& branch_len , entry -> name );
2279+ if ((branch = name_offset (& branch_len , entry -> name )) == NULL ) {
2280+ error = -1 ;
2281+ break ;
2282+ }
22732283
22742284 git_buf_clear (& buf );
2275- if (git_buf_printf (& buf , "branch.%.*s.merge" , (int )branch_len , branch ) < 0 )
2285+ if (( error = git_buf_printf (& buf , "branch.%.*s.merge" , (int )branch_len , branch ) ) < 0 )
22762286 break ;
22772287
22782288 if ((error = git_config_delete_entry (config , git_buf_cstr (& buf ))) < 0 ) {
@@ -2282,7 +2292,7 @@ static int remove_branch_config_related_entries(
22822292 }
22832293
22842294 git_buf_clear (& buf );
2285- if (git_buf_printf (& buf , "branch.%.*s.remote" , (int )branch_len , branch ) < 0 )
2295+ if (( error = git_buf_printf (& buf , "branch.%.*s.remote" , (int )branch_len , branch ) ) < 0 )
22862296 break ;
22872297
22882298 if ((error = git_config_delete_entry (config , git_buf_cstr (& buf ))) < 0 ) {
@@ -2377,7 +2387,8 @@ int git_remote_delete(git_repository *repo, const char *name)
23772387{
23782388 int error ;
23792389
2380- assert (repo && name );
2390+ GIT_ASSERT_ARG (repo );
2391+ GIT_ASSERT_ARG (name );
23812392
23822393 if ((error = remove_branch_config_related_entries (repo , name )) < 0 ||
23832394 (error = remove_remote_tracking (repo , name )) < 0 ||
@@ -2396,7 +2407,7 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
23962407 git_buf local_default = GIT_BUF_INIT ;
23972408 int error ;
23982409
2399- assert (out );
2410+ GIT_ASSERT_ARG (out );
24002411
24012412 if ((error = git_remote_ls (& heads , & heads_len , remote )) < 0 )
24022413 goto done ;
@@ -2465,7 +2476,7 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
24652476 const git_remote_callbacks * cbs = NULL ;
24662477 git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT ;
24672478
2468- assert (remote );
2479+ GIT_ASSERT_ARG (remote );
24692480
24702481 if (!remote -> repo ) {
24712482 git_error_set (GIT_ERROR_INVALID , "cannot download detached remote" );
@@ -2531,7 +2542,7 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
25312542 const git_strarray * custom_headers = NULL ;
25322543 const git_proxy_options * proxy = NULL ;
25332544
2534- assert (remote );
2545+ GIT_ASSERT_ARG (remote );
25352546
25362547 if (!remote -> repo ) {
25372548 git_error_set (GIT_ERROR_INVALID , "cannot download detached remote" );
@@ -2546,8 +2557,6 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
25462557 proxy = & opts -> proxy_opts ;
25472558 }
25482559
2549- assert (remote );
2550-
25512560 if ((error = git_remote_connect (remote , GIT_DIRECTION_PUSH , cbs , proxy , custom_headers )) < 0 )
25522561 return error ;
25532562
@@ -2574,9 +2583,9 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
25742583 git_config_entry * entry ;
25752584 git_config_iterator * iter ;
25762585
2577- assert (config );
2578- assert (url );
2579- assert (direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH );
2586+ GIT_ASSERT_ARG_WITH_RETVAL (config , NULL );
2587+ GIT_ASSERT_ARG_WITH_RETVAL (url , NULL );
2588+ GIT_ASSERT_ARG_WITH_RETVAL (direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH , NULL );
25802589
25812590 /* Add 1 to prefix/suffix length due to the additional escaped dot */
25822591 prefix_length = strlen (PREFIX ) + 1 ;
0 commit comments