ostree-deployment.c: simplify equality check

Just a random cozy patch I made while perusing the codebase. When
determining if two OstreeDeployment objects are the same, rather than
just checking for NULL, we can just directly check for equality of
pointers to also catch the trivial case.

Closes: #1082
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2017-08-16 09:10:39 -04:00 committed by Atomic Bot
parent 6063bdb013
commit fa3a31af92
1 changed files with 5 additions and 5 deletions

View File

@ -160,7 +160,7 @@ ostree_deployment_clone (OstreeDeployment *self)
new_origin = g_key_file_new (); new_origin = g_key_file_new ();
success = g_key_file_load_from_data (new_origin, data, len, 0, NULL); success = g_key_file_load_from_data (new_origin, data, len, 0, NULL);
g_assert (success); g_assert (success);
ostree_deployment_set_origin (ret, new_origin); ostree_deployment_set_origin (ret, new_origin);
} }
return ret; return ret;
@ -187,8 +187,8 @@ ostree_deployment_equal (gconstpointer ap, gconstpointer bp)
{ {
OstreeDeployment *a = (OstreeDeployment*)ap; OstreeDeployment *a = (OstreeDeployment*)ap;
OstreeDeployment *b = (OstreeDeployment*)bp; OstreeDeployment *b = (OstreeDeployment*)bp;
if (a == NULL && b == NULL) if (a == b)
return TRUE; return TRUE;
else if (a != NULL && b != NULL) else if (a != NULL && b != NULL)
return g_str_equal (ostree_deployment_get_osname (a), return g_str_equal (ostree_deployment_get_osname (a),
@ -196,7 +196,7 @@ ostree_deployment_equal (gconstpointer ap, gconstpointer bp)
g_str_equal (ostree_deployment_get_csum (a), g_str_equal (ostree_deployment_get_csum (a),
ostree_deployment_get_csum (b)) && ostree_deployment_get_csum (b)) &&
ostree_deployment_get_deployserial (a) == ostree_deployment_get_deployserial (b); ostree_deployment_get_deployserial (a) == ostree_deployment_get_deployserial (b);
else else
return FALSE; return FALSE;
} }
@ -236,7 +236,7 @@ ostree_deployment_new (int index,
int bootserial) int bootserial)
{ {
OstreeDeployment *self; OstreeDeployment *self;
/* index may be -1 */ /* index may be -1 */
g_return_val_if_fail (osname != NULL, NULL); g_return_val_if_fail (osname != NULL, NULL);
g_return_val_if_fail (csum != NULL, NULL); g_return_val_if_fail (csum != NULL, NULL);