summaryrefslogtreecommitdiff
path: root/firmware/2lib/2gbb.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/2lib/2gbb.c')
-rw-r--r--firmware/2lib/2gbb.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/firmware/2lib/2gbb.c b/firmware/2lib/2gbb.c
index 8a7c57c5..c7f22564 100644
--- a/firmware/2lib/2gbb.c
+++ b/firmware/2lib/2gbb.c
@@ -39,8 +39,7 @@ static int vb2_gbb_read_key(struct vb2_context *ctx,
/* Deal with a zero-size key (used in testing). */
*size = (*keyp)->key_offset + (*keyp)->key_size;
- if (*size < sizeof(**keyp))
- *size = sizeof(**keyp);
+ *size = VB2_MAX(*size, sizeof(**keyp));
/* Now that we know the real size of the key, retrieve the key
data, and write it on the workbuf, directly after vb2_packed_key. */
@@ -98,10 +97,8 @@ int vb2api_gbb_read_hwid(struct vb2_context *ctx,
return VB2_ERROR_GBB_INVALID;
}
- if (*size > VB2_GBB_HWID_MAX_SIZE)
- *size = VB2_GBB_HWID_MAX_SIZE;
- if (*size > gbb->hwid_size)
- *size = gbb->hwid_size;
+ *size = VB2_MIN(*size, VB2_GBB_HWID_MAX_SIZE);
+ *size = VB2_MIN(*size, gbb->hwid_size);
ret = vb2ex_read_resource(ctx, VB2_RES_GBB, gbb->hwid_offset,
hwid, *size);