aboutsummaryrefslogtreecommitdiffstats
path: root/src/lg-downloader.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2016-01-27 20:54:50 +0100
committerPaul Kocialkowski <contact@paulk.fr>2016-01-27 20:58:23 +0100
commitd036034922795d8af1d8cefc5bf466882262782f (patch)
treee92be65561abdaa453b98246188135c85e110cc0 /src/lg-downloader.c
parent2e31eedce5bc7d2fc37f8cd6be1a7177dd7f6da7 (diff)
downloadlg-downloader-d036034922795d8af1d8cefc5bf466882262782f.tar.gz
lg-downloader-d036034922795d8af1d8cefc5bf466882262782f.tar.bz2
lg-downloader-d036034922795d8af1d8cefc5bf466882262782f.zip
Use fixed-size stdint types and sys types
Generic C types only guarantee a minimum size, not a fixed size, so it is necessary to use stdint types for fixed-size variables. Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'src/lg-downloader.c')
-rw-r--r--src/lg-downloader.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/lg-downloader.c b/src/lg-downloader.c
index 5c3ecfc..c41ebd0 100644
--- a/src/lg-downloader.c
+++ b/src/lg-downloader.c
@@ -17,8 +17,10 @@
#include <stdlib.h>
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
#include <fcntl.h>
+#include <sys/types.h>
#include <sys/stat.h>
#include "lg-downloader.h"
@@ -101,7 +103,7 @@ int erase(struct context *context)
}
if (context->verbose)
- printf("Erasing partition with address %d blocks and length %d bytes\n", context->address, context->length);
+ printf("Erasing partition with address %d blocks and length %d bytes\n", (int) context->address, (int) context->length);
rc = download_erase(context, context->address, context->length);
if (rc < 0)
@@ -113,12 +115,12 @@ int erase(struct context *context)
int flash(struct context *context)
{
void *buffer = NULL;
- unsigned int address;
- unsigned int length;
- unsigned int count;
- unsigned int chunk;
- unsigned char *p;
- unsigned int i;
+ off_t address;
+ size_t length;
+ size_t count;
+ size_t chunk;
+ uint8_t *p;
+ size_t i;
struct stat st;
int fd = -1;
int rc;
@@ -141,7 +143,7 @@ int flash(struct context *context)
length = st.st_size;
if (length > context->length) {
- fprintf(stderr, "File size (%d bytes) is too big for partition (%d bytes)\n", length, context->length);
+ fprintf(stderr, "File size (%d bytes) is too big for partition (%d bytes)\n", (int) length, (int) context->length);
goto error;
}
@@ -152,7 +154,7 @@ int flash(struct context *context)
}
if (context->verbose)
- printf("Writing to partition with address %d blocks and length %d bytes\n", context->address, length);
+ printf("Writing to partition with address %d blocks and length %d bytes\n", (int) context->address, (int) length);
buffer = calloc(1, GPT_BLOCK_SIZE);
@@ -174,7 +176,7 @@ int flash(struct context *context)
if (chunk < GPT_BLOCK_SIZE)
memset(buffer, 0, GPT_BLOCK_SIZE);
- p = (unsigned char *) buffer;
+ p = (uint8_t *) buffer;
i = 0;
while (i < chunk) {
@@ -213,12 +215,12 @@ complete:
int dump(struct context *context)
{
void *buffer = NULL;
- unsigned int address;
- unsigned int length;
- unsigned int count;
- unsigned int chunk;
- unsigned char *p;
- unsigned int c;
+ off_t address;
+ size_t length;
+ size_t count;
+ size_t chunk;
+ uint8_t *p;
+ size_t c;
int fd = -1;
int rc;
@@ -238,7 +240,7 @@ int dump(struct context *context)
}
if (context->verbose)
- printf("Dumping partition with address %d blocks and length %d bytes\n", context->address, context->length);
+ printf("Dumping partition with address %d blocks and length %d bytes\n", (int) context->address, (int) context->length);
buffer = calloc(1, GPT_BLOCK_SIZE);
@@ -264,7 +266,7 @@ int dump(struct context *context)
goto error;
c = 0;
- p = (unsigned char *) buffer;
+ p = (uint8_t *) buffer;
while (c < chunk) {
rc = write(fd, p, chunk - c);