Re: [PATCH v2 02/13] refs.c: use a single exit path from transaction commit and handle onerr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ronnie Sahlberg <sahlberg@xxxxxxxxxx> writes:

> @@ -3481,6 +3481,14 @@ cleanup:
>  			unlock_ref(updates[i]->lock);
>  	free(delnames);
>  	ref_transaction_free(transaction);
> +	if (ret) {
> +		const char *str = "Cannot commit transaction.";
> +		switch (onerr) {
> +		case UPDATE_REFS_MSG_ON_ERR: error(str); break;
> +		case UPDATE_REFS_DIE_ON_ERR: die(str); break;
> +		case UPDATE_REFS_QUIET_ON_ERR: break;
> +		}
> +	}
>  	return ret;
>  }

Also on top of this part:

 - avoid complier warning for printf-like functions getting a non
   literal format string as their format argument;

 - style: case label and each statement on its own line.

 - Allow localizing the error message.

diff --git a/refs.c b/refs.c
index e52b6bf..35ce61a 100644
--- a/refs.c
+++ b/refs.c
@@ -3515,11 +3515,16 @@ cleanup:
 	free(delnames);
 	ref_transaction_free(transaction);
 	if (ret) {
-		const char *str = "Cannot commit transaction.";
+		const char *str = _("Cannot commit transaction.");
 		switch (onerr) {
-		case UPDATE_REFS_MSG_ON_ERR: error(str); break;
-		case UPDATE_REFS_DIE_ON_ERR: die(str); break;
-		case UPDATE_REFS_QUIET_ON_ERR: break;
+		case UPDATE_REFS_MSG_ON_ERR:
+			error("%s", str);
+			break;
+		case UPDATE_REFS_DIE_ON_ERR:
+			die("%s", str);
+			break;
+		case UPDATE_REFS_QUIET_ON_ERR:
+			break;
 		}
 	}
 	return ret;
-- 
2.0.0-rc0-187-g5842ffa

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]