summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.mk4
-rw-r--r--logotool/compress.c1
-rw-r--r--logotool/rgb2yuv.c2
-rw-r--r--logotool/uncompress.c1
-rw-r--r--src/dump.c8
-rw-r--r--src/fpid.c7
-rw-r--r--src/hash.c4
-rw-r--r--src/qmode.c49
-rw-r--r--src/squeue/squeue.c7
9 files changed, 49 insertions, 34 deletions
diff --git a/config.mk b/config.mk
index 80b1284..d116daa 100644
--- a/config.mk
+++ b/config.mk
@@ -7,3 +7,7 @@ LDFLAGS+=-L/usr/pkg/lib -Wl,-R/usr/pkg/lib
HAVE_USB=1
HAVE_GUI=1
+
+# For linking against this copy of libusb
+#CFLAGS+=-I../libusb
+
diff --git a/logotool/compress.c b/logotool/compress.c
index c65158c..cb32265 100644
--- a/logotool/compress.c
+++ b/logotool/compress.c
@@ -60,6 +60,7 @@ int compress_image(char *srcf, char *dstf, int w, int h)
fdout = open( dstf, O_TRUNC | O_CREAT | O_WRONLY , 0660 );
if (fdout == -1) {
printf("Cannot open file '%s' for writing\n", dstf);
+ fclose(fd);
return 1;
}
diff --git a/logotool/rgb2yuv.c b/logotool/rgb2yuv.c
index b3f2143..4c3a268 100644
--- a/logotool/rgb2yuv.c
+++ b/logotool/rgb2yuv.c
@@ -107,5 +107,7 @@ int rgb2yuv(char *from, char *to, int width, int height)
for ( i = 0 ; i < height ; i+=2 )
for ( j = 0; j < width ; j +=2 )
write ( fout,&dstV[j+(i*width)], 1);
+
+ free(dstV); free(dstU); free(dstY); free(src);
return 1;
}
diff --git a/logotool/uncompress.c b/logotool/uncompress.c
index 7fb8b10..72b1fdd 100644
--- a/logotool/uncompress.c
+++ b/logotool/uncompress.c
@@ -119,5 +119,6 @@ int uncompress_image(char *srcf, char *dstf)
//printf("logotool -w %d -h %d -v %s\n", width, height, dstf);
printf("eval PATH=$PWD:$PATH logotool -w %d -h %d -m %s\n", width, height, dstf);
+ free(dst); free(src);
return 0;
}
diff --git a/src/dump.c b/src/dump.c
index 9fc0a86..02025e5 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -69,17 +69,14 @@ __rf_extract_exit:
* This function was covardly copied from nanddump.c @ mtd-utils-20060907
*/
#define _GNU_SOURCE
-#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/ioctl.h>
#include <sys/types.h>
-#include <sys/stat.h>
//#include <asm/types.h>
#include <mtd/mtd-user.h>
#ifndef loff_t
@@ -172,6 +169,9 @@ int check_badblocks(char *mtddev)
return 1;
}
+ memset(&stat1, 0, sizeof(stat1));
+ memset(&stat2, 0, sizeof(stat2));
+
fprintf(stderr, "Block size %u, page size %u, OOB size %u\n",
meminfo.erasesize, meminfo.writesize, meminfo.oobsize);
fprintf(stderr, "Size %u, flags %u, type 0x%x\n",
@@ -513,7 +513,7 @@ int dump_config()
break;
if (!memcmp(buf,"ConF", 4)) {
loop:
- read(fd, buf, 4);
+ ret = read(fd, buf, 4);
if (ret == -1) break;
printf("\n0x%08x : ConF %02x %02x %02x %02x : ", i,
buf[0], buf[1], buf[2], buf[3]);
diff --git a/src/fpid.c b/src/fpid.c
index 60c1381..7126719 100644
--- a/src/fpid.c
+++ b/src/fpid.c
@@ -42,7 +42,12 @@ long fpid_size(const char *filename)
{
long sz;
FILE *fd = fopen(filename, "r");
- fseek(fd, 0, SEEK_END);
+ if (fd == NULL)
+ return -1;
+ if (fseek(fd, 0, SEEK_END) != 0) {
+ fclose(fd);
+ return -1;
+ }
sz = ftell(fd);
fclose(fd);
return sz;
diff --git a/src/hash.c b/src/hash.c
index 9090bad..cc17492 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -44,8 +44,10 @@ usho do_hash_file(const char *filename, const char *type)
do {
ret = fread(&buf, 1, BSIZE, fd);
- if (ret == -1)
+ if (ret == -1) {
+ fclose(fd);
return 0;
+ }
hash ^= do_hash((usho *)&buf, ret);
} while(ret);
diff --git a/src/qmode.c b/src/qmode.c
index 64ee94a..e23e457 100644
--- a/src/qmode.c
+++ b/src/qmode.c
@@ -43,38 +43,33 @@ void process_message(char *msg)
{
char *str;
char *arg;
- int c=1;
if (msg == NULL)
return;
printf("[x] (%s)\n", msg);
str = strdup(msg);
arg = strchr(str, ':');
- if (c!=0) {
- arg[0]='\0';
- arg = arg +1;
- if (!strcmp(str, "flash")) {
- const char *type = fpid_file(arg);
- if (type == NULL) {
- squeue_push2(p, "error", "Unknown piece format", 1);
- } else flash_image(arg, type, NULL, NULL, NULL);
- } else
- if (!strcmp(str, "reset")) {
- if (reboot_board() == 0) {
- squeue_push2(p,"info", "Device reboots", 1);
- } else squeue_push2(p,"error", "Cannot reboot device", 1);
- } else
- if (!strcmp(str, "info")) {
- get_rd_flags();
- squeue_push2(p, "info", strbuf, 1);
- get_nolo_version();
- squeue_push2(p, "info", strbuf, 1);
- get_usb_mode();
- squeue_push2(p, "info", strbuf, 1);
- } else
- squeue_push2(p, "error", "invalid command", 0);
- } else {
- squeue_push2(p, "error", "invalid command format", 0);
- }
+ arg[0]='\0';
+ arg = arg +1;
+ if (!strcmp(str, "flash")) {
+ const char *type = fpid_file(arg);
+ if (type == NULL) {
+ squeue_push2(p, "error", "Unknown piece format", 1);
+ } else flash_image(arg, type, NULL, NULL, NULL);
+ } else
+ if (!strcmp(str, "reset")) {
+ if (reboot_board() == 0) {
+ squeue_push2(p,"info", "Device reboots", 1);
+ } else squeue_push2(p,"error", "Cannot reboot device", 1);
+ } else
+ if (!strcmp(str, "info")) {
+ get_rd_flags();
+ squeue_push2(p, "info", strbuf, 1);
+ get_nolo_version();
+ squeue_push2(p, "info", strbuf, 1);
+ get_usb_mode();
+ squeue_push2(p, "info", strbuf, 1);
+ } else
+ squeue_push2(p, "error", "invalid command", 0);
free(str);
}
diff --git a/src/squeue/squeue.c b/src/squeue/squeue.c
index 69bd595..0ed8815 100644
--- a/src/squeue/squeue.c
+++ b/src/squeue/squeue.c
@@ -40,13 +40,18 @@ struct squeue_t *squeue_open(const char *file, int mode)
struct squeue_t *q;
char *pool;
int shmid;
+ int fd;
key_t k;
k = ftok(file, 0x34);
if (k == -1) {
perror("ftok");
squeue_release(file);
- close(creat(file, 0666));
+ if ((fd = creat(file, 0666)) == -1) {
+ perror("creat");
+ return NULL;
+ }
+ close(fd);
chmod(file, 0666);
k = ftok(file, 0xa3);
if (k == -1) {