steadmon@xxxxxxxxxx writes: > + if (tmp_allowed_versions[0] != config_version) > + for (int i = 1; i < nr_allowed_versions; i++) > + if (tmp_allowed_versions[i] == config_version) { > + enum protocol_version swap = > + tmp_allowed_versions[0]; > + tmp_allowed_versions[0] = > + tmp_allowed_versions[i]; > + tmp_allowed_versions[i] = swap; > + } Here is what coccicheck suggests. diff -u -p a/protocol.c b/protocol.c --- a/protocol.c +++ b/protocol.c @@ -111,11 +111,8 @@ void get_client_protocol_version_adverti if (tmp_allowed_versions[0] != config_version) for (int i = 1; i < nr_allowed_versions; i++) if (tmp_allowed_versions[i] == config_version) { - enum protocol_version swap = - tmp_allowed_versions[0]; - tmp_allowed_versions[0] = - tmp_allowed_versions[i]; - tmp_allowed_versions[i] = swap; + SWAP(tmp_allowed_versions[0], + tmp_allowed_versions[i]); } strbuf_addf(advert, "version=%s",