Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157065647
D6178.id15825.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D6178.id15825.diff
View Options
Index: usr.sbin/vidcontrol/vidcontrol.c
===================================================================
--- usr.sbin/vidcontrol/vidcontrol.c
+++ usr.sbin/vidcontrol/vidcontrol.c
@@ -393,12 +393,11 @@
if (nmappings == 0)
return (NULL);
- t = malloc(sizeof *t * nmappings);
+ if ((t = malloc(sizeof *t * nmappings)) == NULL)
+ err(1, "malloc");
- if (fread(t, sizeof *t * nmappings, 1, f) != 1) {
- perror("mappings");
- exit(1);
- }
+ if (fread(t, sizeof *t * nmappings, 1, f) != 1)
+ err(1, "read mappings");
for (i = 0; i < nmappings; i++) {
t[i].src = be32toh(t[i].src);
@@ -422,7 +421,7 @@
}
}
-static int
+static void
load_vt4font(FILE *f)
{
struct vt4font_header fh;
@@ -430,15 +429,11 @@
size_t glyphsize;
unsigned int i;
- if (fread(&fh, sizeof fh, 1, f) != 1) {
- perror("file_header");
- return (1);
- }
+ if (fread(&fh, sizeof fh, 1, f) != 1)
+ err(1, "read file_header");
- if (memcmp(fh.magic, "VFNT0002", 8) != 0) {
- fprintf(stderr, "Bad magic\n");
- return (1);
- }
+ if (memcmp(fh.magic, "VFNT0002", 8) != 0)
+ errx(1, "Bad magic in font file\n");
for (i = 0; i < VFNT_MAPS; i++)
vfnt.map_count[i] = be32toh(fh.map_count[i]);
@@ -447,21 +442,21 @@
vfnt.height = fh.height;
glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count;
- vfnt.glyphs = malloc(glyphsize);
+ if ((vfnt.glyphs = malloc(glyphsize)) == NULL)
+ err(1, "malloc");
- if (fread(vfnt.glyphs, glyphsize, 1, f) != 1) {
- perror("glyphs");
- return (1);
- }
+ if (fread(vfnt.glyphs, glyphsize, 1, f) != 1)
+ err(1, "read glyphs");
for (i = 0; i < VFNT_MAPS; i++)
vfnt.map[i] = load_vt4mappingtable(vfnt.map_count[i], f);
- if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1) {
- perror("PIO_VFONT");
- return (1);
- }
- return (0);
+ if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1)
+ err(1, "PIO_VFONT");
+
+ for (i = 0; i < VFNT_MAPS; i++)
+ free(vfnt.map[i]);
+ free(vfnt.glyphs);
}
/*
@@ -511,8 +506,7 @@
}
if (vt4_mode) {
- if(load_vt4font(fd))
- warn("failed to load font \"%s\"", filename);
+ load_vt4font(fd);
fclose(fd);
return;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 19, 6:00 AM (13 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33295761
Default Alt Text
D6178.id15825.diff (2 KB)
Attached To
Mode
D6178: vidcontrol: improve error handling
Attached
Detach File
Event Timeline
Log In to Comment