Commit 48e81485 authored by Benjamin Romer's avatar Benjamin Romer Committed by Greg Kroah-Hartman

staging: unisys: refactor parser_init_guts()

Fix CamelCase names:

isLocal => local
hasStandardPayloadHeader => standard_payload_header
tryAgain => retry
Away => cleanup

Fix spacing after typecasts, add missing braces to the if statement, and
eliminate the NULL comparison by just using the pointer value directly.
Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 317d9614
...@@ -41,8 +41,8 @@ struct parser_context { ...@@ -41,8 +41,8 @@ struct parser_context {
}; };
static struct parser_context * static struct parser_context *
parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, parser_init_guts(u64 addr, u32 bytes, BOOL local,
BOOL hasStandardPayloadHeader, BOOL *tryAgain) BOOL standard_payload_header, BOOL *retry)
{ {
int allocbytes = sizeof(struct parser_context) + bytes; int allocbytes = sizeof(struct parser_context) + bytes;
struct parser_context *rc = NULL; struct parser_context *rc = NULL;
...@@ -50,26 +50,26 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, ...@@ -50,26 +50,26 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
struct memregion *rgn = NULL; struct memregion *rgn = NULL;
struct spar_controlvm_parameters_header *phdr = NULL; struct spar_controlvm_parameters_header *phdr = NULL;
if (tryAgain) if (retry)
*tryAgain = FALSE; *retry = FALSE;
if (!hasStandardPayloadHeader) if (!standard_payload_header)
/* alloc and 0 extra byte to ensure payload is /* alloc and 0 extra byte to ensure payload is
* '\0'-terminated * '\0'-terminated
*/ */
allocbytes++; allocbytes++;
if ((controlvm_payload_bytes_buffered + bytes) if ((controlvm_payload_bytes_buffered + bytes)
> MAX_CONTROLVM_PAYLOAD_BYTES) { > MAX_CONTROLVM_PAYLOAD_BYTES) {
if (tryAgain) if (retry)
*tryAgain = TRUE; *retry = TRUE;
rc = NULL; rc = NULL;
goto Away; goto cleanup;
} }
ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY); ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
if (ctx == NULL) { if (!ctx) {
if (tryAgain) if (retry)
*tryAgain = TRUE; *retry = TRUE;
rc = NULL; rc = NULL;
goto Away; goto cleanup;
} }
ctx->allocbytes = allocbytes; ctx->allocbytes = allocbytes;
...@@ -77,12 +77,12 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, ...@@ -77,12 +77,12 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
ctx->curr = NULL; ctx->curr = NULL;
ctx->bytes_remaining = 0; ctx->bytes_remaining = 0;
ctx->byte_stream = FALSE; ctx->byte_stream = FALSE;
if (isLocal) { if (local) {
void *p; void *p;
if (addr > virt_to_phys(high_memory - 1)) { if (addr > virt_to_phys(high_memory - 1)) {
rc = NULL; rc = NULL;
goto Away; goto cleanup;
} }
p = __va((ulong) (addr)); p = __va((ulong) (addr));
memcpy(ctx->data, p, bytes); memcpy(ctx->data, p, bytes);
...@@ -90,42 +90,42 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, ...@@ -90,42 +90,42 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
rgn = visor_memregion_create(addr, bytes); rgn = visor_memregion_create(addr, bytes);
if (!rgn) { if (!rgn) {
rc = NULL; rc = NULL;
goto Away; goto cleanup;
} }
if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) { if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
rc = NULL; rc = NULL;
goto Away; goto cleanup;
} }
} }
if (!hasStandardPayloadHeader) { if (!standard_payload_header) {
ctx->byte_stream = TRUE; ctx->byte_stream = TRUE;
rc = ctx; rc = ctx;
goto Away; goto cleanup;
} }
phdr = (struct spar_controlvm_parameters_header *)(ctx->data); phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
if (phdr->total_length != bytes) { if (phdr->total_length != bytes) {
rc = NULL; rc = NULL;
goto Away; goto cleanup;
} }
if (phdr->total_length < phdr->header_length) { if (phdr->total_length < phdr->header_length) {
rc = NULL; rc = NULL;
goto Away; goto cleanup;
} }
if (phdr->header_length < if (phdr->header_length <
sizeof(struct spar_controlvm_parameters_header)) { sizeof(struct spar_controlvm_parameters_header)) {
rc = NULL; rc = NULL;
goto Away; goto cleanup;
} }
rc = ctx; rc = ctx;
Away: cleanup:
if (rgn) { if (rgn) {
visor_memregion_destroy(rgn); visor_memregion_destroy(rgn);
rgn = NULL; rgn = NULL;
} }
if (rc) if (rc) {
controlvm_payload_bytes_buffered += ctx->param_bytes; controlvm_payload_bytes_buffered += ctx->param_bytes;
else { } else {
if (ctx) { if (ctx) {
parser_done(ctx); parser_done(ctx);
ctx = NULL; ctx = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment