projects
/
emu8051.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
310d829
)
Use log functions to display errors
author
Hugo Villeneuve
<hugo@hugovil.com>
Sun, 26 Jan 2014 20:23:48 +0000
(15:23 -0500)
committer
Hugo Villeneuve
<hugo@hugovil.com>
Sun, 26 Jan 2014 20:38:46 +0000
(15:38 -0500)
src/common/hexfile.c
patch
|
blob
|
history
src/common/memory.c
patch
|
blob
|
history
src/gtk/memwin.c
patch
|
blob
|
history
src/gtk/pgmwin.c
patch
|
blob
|
history
src/gtk/pswwin.c
patch
|
blob
|
history
src/gtk/regwin.c
patch
|
blob
|
history
diff --git
a/src/common/hexfile.c
b/src/common/hexfile.c
index
6411166
..
c879c89
100644
(file)
--- a/
src/common/hexfile.c
+++ b/
src/common/hexfile.c
@@
-85,8
+85,8
@@
Ascii2Hex(char *istring, int length)
result <<= 4;
result += ascii_code;
} else {
result <<= 4;
result += ascii_code;
} else {
- printf("%s: In Ascii2Hex(), syntax error.\n", PACKAGE);
-
printf(" str=%s, length=%d\n
", istring, length);
+ log_fail("Error converting ASCII string <%s> to hex"
+
" (len=%d)
", istring, length);
}
}
return result;
}
}
return result;
@@
-102,18
+102,14
@@
LoadHexFile(const char *filename)
int status;
char line[LINE_BUFFER_LEN];
int status;
char line[LINE_BUFFER_LEN];
- if (filename == NULL) {
- printf("%s: No file specified\n", PACKAGE);
- exit(EXIT_FAILURE);
- }
+ if (filename == NULL)
+ log_fail("No file specified");
/* Trying to open the file. */
fp = fopen(filename, "r");
/* Trying to open the file. */
fp = fopen(filename, "r");
- if (fp == NULL) {
- perror(filename);
- /*ErrorLocation(__FILE__, __LINE__);*/
- exit(EXIT_FAILURE);
- }
+ if (fp == NULL)
+ log_fail("Error opening hex file <%s>: %s", filename,
+ strerror(errno));
/* Reading one line of data from the hex file. */
/* char *fgets(char *s, int size, FILE *stream);
/* Reading one line of data from the hex file. */
/* char *fgets(char *s, int size, FILE *stream);
@@
-126,7
+122,7
@@
LoadHexFile(const char *filename)
Checksum = 0;
if (line[i++] != ':') {
Checksum = 0;
if (line[i++] != ':') {
-
printf("%s: line not beginning with \":\"\n", PACKAGE
);
+
log_err("hexfile line not beginning with \":\""
);
goto close_file;
}
goto close_file;
}
@@
-148,8
+144,7
@@
LoadHexFile(const char *filename)
Checksum &= 0x000000FF;
if (Checksum) {
Checksum &= 0x000000FF;
if (Checksum) {
- /* Error. */
- printf("%s: Invalid format\n", PACKAGE);
+ log_err("hexfile invalid format");
goto close_file;
} else {
/* OK */
goto close_file;
} else {
/* OK */
@@
-171,16
+166,13
@@
LoadHexFile(const char *filename)
Checksum &= 0x000000FF;
if (Checksum) {
Checksum &= 0x000000FF;
if (Checksum) {
-
printf("%s: Invalid format\n", PACKAGE
);
+
log_err("hexfile checksum mismatch"
);
goto close_file;
}
}
close_file:
status = fclose(fp);
goto close_file;
}
}
close_file:
status = fclose(fp);
- if (status != EXIT_SUCCESS) {
- fprintf(stderr, "%s: Error closing hex file.\n", PACKAGE);
- /*ErrorLocation(__FILE__, __LINE__);*/
- exit(EXIT_FAILURE);
- }
+ if (status != EXIT_SUCCESS)
+ log_fail("Error closing hex file");
}
}
diff --git
a/src/common/memory.c
b/src/common/memory.c
index
bd33cac
..
2e37210
100644
(file)
--- a/
src/common/memory.c
+++ b/
src/common/memory.c
@@
-91,9
+91,9
@@
void
memory_write8(enum mem_id_t id, unsigned long address, u_int8_t value)
{
if (address >= (unsigned long) mem_infos[id].max_size) {
memory_write8(enum mem_id_t id, unsigned long address, u_int8_t value)
{
if (address >= (unsigned long) mem_infos[id].max_size) {
- printf("Error writing to memory ID: %d\n", id);
-
printf(" Address (%lu) greater than maximum memory size\n
",
- address);
+ log_err("Error writing to memory ID: %d\n"
+
" Address (%lu) greater than maximum memory size
",
+
id,
address);
return;
} else
mem_infos[id].buf[address] = value;
return;
} else
mem_infos[id].buf[address] = value;
@@
-117,9
+117,9
@@
u_int8_t
memory_read8(enum mem_id_t id, unsigned long address)
{
if (address >= (unsigned long) mem_infos[id].max_size) {
memory_read8(enum mem_id_t id, unsigned long address)
{
if (address >= (unsigned long) mem_infos[id].max_size) {
- printf("Error reading from memory ID: %d\n", id);
-
printf(" Address (%lu) greater than maximum memory size\n
",
- address);
+ log_err("Error reading from memory ID: %d\n"
+
" Address (%lu) greater than maximum memory size
",
+
id,
address);
return 0;
} else
return mem_infos[id].buf[address];
return 0;
} else
return mem_infos[id].buf[address];
diff --git
a/src/gtk/memwin.c
b/src/gtk/memwin.c
index
dae27a9
..
c525fb1
100644
(file)
--- a/
src/gtk/memwin.c
+++ b/
src/gtk/memwin.c
@@
-349,7
+349,7
@@
memwin_refresh(int memory_id)
}
if (!valid) {
}
if (!valid) {
-
printf("Invalid iter...\n
");
+
log_err("Tree model: invalid iter
");
return;
}
return;
}
diff --git
a/src/gtk/pgmwin.c
b/src/gtk/pgmwin.c
index
15f26b5
..
6db09e4
100644
(file)
--- a/
src/gtk/pgmwin.c
+++ b/
src/gtk/pgmwin.c
@@
-241,7
+241,7
@@
pgmwin_refresh(void)
}
if (!valid) {
}
if (!valid) {
-
printf("Invalid iter...\n
");
+
log_err("Tree model: invalid iter
");
return;
}
return;
}
diff --git
a/src/gtk/pswwin.c
b/src/gtk/pswwin.c
index
94f733c
..
6b890d0
100644
(file)
--- a/
src/gtk/pswwin.c
+++ b/
src/gtk/pswwin.c
@@
-230,7
+230,7
@@
pswwin_refresh(void)
GTK_TREE_MODEL(store), &iter);
if (!valid) {
GTK_TREE_MODEL(store), &iter);
if (!valid) {
-
printf("Invalid iter...\n
");
+
log_err("Tree model: invalid iter
");
return;
}
return;
}
diff --git
a/src/gtk/regwin.c
b/src/gtk/regwin.c
index
af16a7c
..
8b470a9
100644
(file)
--- a/
src/gtk/regwin.c
+++ b/
src/gtk/regwin.c
@@
-239,7
+239,7
@@
regwin_refresh(void)
}
if (!valid) {
}
if (!valid) {
-
printf("Invalid iter...\n
");
+
log_err("Tree model: invalid iter
");
return;
}
return;
}