Removed all traces of sprintf() from all server code and

from all drivers.  All drivers compile without warnings.
This commit is contained in:
ddouthitt
2001-09-25 15:02:33 +00:00
parent 0307a9112e
commit 44e7f83dfd
8 changed files with 33 additions and 33 deletions
+2 -2
View File
@@ -110,7 +110,7 @@ hello_func (client * c, int argc, char **argv)
debug ("Hello!\n"); debug ("Hello!\n");
memset(str, '\0', sizeof(str)); memset(str, '\0', sizeof(str));
sprintf (str, "connect LCDproc %s protocol %s lcd wid %i hgt %i cellwid %i cellhgt %i\n", snprintf (str, sizeof(str), "connect LCDproc %s protocol %s lcd wid %i hgt %i cellwid %i cellhgt %i\n",
version, protocol_version, lcd.wid, lcd.hgt, lcd.cellwid, lcd.cellhgt); version, protocol_version, lcd.wid, lcd.hgt, lcd.cellwid, lcd.cellhgt);
// lcdproc (client) depends on the above format... // lcdproc (client) depends on the above format...
@@ -1433,7 +1433,7 @@ sleep_func (client * c, int argc, char **argv)
// Repeat until no more remains - should normally be zero // Repeat until no more remains - should normally be zero
// on exit the first time... // on exit the first time...
sprintf(str, "sleeping %d seconds\n", secs); snprintf(str, sizeof(str), "sleeping %d seconds\n", secs);
sock_send_string (c->sock, str); sock_send_string (c->sock, str);
// whoops.... if this takes place as planned, ALL screens // whoops.... if this takes place as planned, ALL screens
+2 -2
View File
@@ -306,7 +306,7 @@ CFontz_backlight (int on)
char out[4]; char out[4];
if (on) { if (on) {
snprintf (out, sizeof(out), "%c%c", 14, (unsigned char) (on * 100 / 255)); snprintf (out, sizeof(out), "%c%c", 14, (unsigned char) (on * 100 / 255));
//sprintf(out, "%c%c", 14, 100); //snprintf(out, sizeof(out), "%c%c", 14, 100);
} else { } else {
snprintf (out, sizeof(out), "%c%c", 14, 0); snprintf (out, sizeof(out), "%c%c", 14, 0);
} }
@@ -694,7 +694,7 @@ CFontz_draw_frame (char *dat)
write (fd, dat + (CFontz->wid * i), CFontz->wid); write (fd, dat + (CFontz->wid * i), CFontz->wid);
} }
/* /*
sprintf(out, "%c", 1); snprintf(out, sizeof(out), "%c", 1);
write(fd, out, 1); write(fd, out, 1);
write(fd, dat, CFontz->wid*CFontz->hgt); write(fd, dat, CFontz->wid*CFontz->hgt);
*/ */
+12 -12
View File
@@ -421,7 +421,7 @@ MtxOrb_flush_box (int lft, int top, int rgt, int bot)
char out[LCD_MAX_WIDTH]; char out[LCD_MAX_WIDTH];
for (y = top; y <= bot; y++) { for (y = top; y <= bot; y++) {
sprintf (out, "\x0FEG%c%c", lft, y); snprintf (out, sizeof(out), "\x0FEG%c%c", lft, y);
write (fd, out, 4); write (fd, out, 4);
write (fd, MtxOrb->framebuf + (y * MtxOrb->wid) + lft, rgt - lft + 1); write (fd, MtxOrb->framebuf + (y * MtxOrb->wid) + lft, rgt - lft + 1);
@@ -447,7 +447,7 @@ MtxOrb_chr (int x, int y, char c)
// write immediately to screen... this code was taken // write immediately to screen... this code was taken
// from the LK202-25; should work for others, yes? // from the LK202-25; should work for others, yes?
// sprintf(out, "\x0FEG%c%c%c", x, y, c); // snprintf(out, sizeof(out), "\x0FEG%c%c%c", x, y, c);
// write (fd, out, 4); // write (fd, out, 4);
// write to frame buffer // write to frame buffer
@@ -479,7 +479,7 @@ MtxOrb_contrast (int contrast)
contrast = 0; contrast = 0;
if (IS_LCD_DISPLAY || IS_LKD_DISPLAY) { if (IS_LCD_DISPLAY || IS_LKD_DISPLAY) {
sprintf (out, "\x0FEP%c", contrast); snprintf (out, sizeof(out), "\x0FEP%c", contrast);
write (fd, out, 3); write (fd, out, 3);
} }
return contrast; return contrast;
@@ -541,8 +541,8 @@ MtxOrb_output (int on)
on = on & 077; // strip to six bits on = on & 077; // strip to six bits
for(i = 0; i < 6; i++) { for(i = 0; i < 6; i++) {
(on & (1 << i)) ? (on & (1 << i)) ?
sprintf (out, "\x0FEW%c", i + 1) : snprintf (out, sizeof(out), "\x0FEW%c", i + 1) :
sprintf (out, "\x0FEV%c", i + 1); snprintf (out, sizeof(out), "\x0FEV%c", i + 1);
write (fd, out, 3); write (fd, out, 3);
} }
} }
@@ -664,7 +664,7 @@ MtxOrb_getinfo (void)
case '\x33': strcat(info, "LK402-12 "); break; case '\x33': strcat(info, "LK402-12 "); break;
case '\x34': strcat(info, "LK162-12 "); break; case '\x34': strcat(info, "LK162-12 "); break;
case '\x35': strcat(info, "LK204-25PC "); break; case '\x35': strcat(info, "LK204-25PC "); break;
default: //sprintf(tmp, "Unknown (%X) ", in); strcat(info, tmp); default: //snprintf(tmp, sizeof(tmp), "Unknown (%X) ", in); strcat(info, tmp);
break; break;
} }
} }
@@ -688,7 +688,7 @@ MtxOrb_getinfo (void)
if (read (fd, &tmp, 2) < 0) { if (read (fd, &tmp, 2) < 0) {
syslog(LOG_WARNING, "MatrixOrbital driver: unable to read data"); syslog(LOG_WARNING, "MatrixOrbital driver: unable to read data");
} else { } else {
sprintf(buf, "Serial No: %ld ", (long int) tmp); snprintf(buf, sizeof(buf), "Serial No: %ld ", (long int) tmp);
strcat(info, buf); strcat(info, buf);
} }
} else } else
@@ -711,7 +711,7 @@ MtxOrb_getinfo (void)
if (read (fd, &tmp, 2) < 0) { if (read (fd, &tmp, 2) < 0) {
syslog(LOG_WARNING, "MatrixOrbital driver: unable to read data"); syslog(LOG_WARNING, "MatrixOrbital driver: unable to read data");
} else { } else {
sprintf(buf, "Firmware Rev. %ld ", (long int) tmp); snprintf(buf, sizeof(buf), "Firmware Rev. %ld ", (long int) tmp);
strcat(info, buf); strcat(info, buf);
} }
} else } else
@@ -823,7 +823,7 @@ static void
MtxOrb_num (int x, int num) MtxOrb_num (int x, int num)
{ {
char out[5]; char out[5];
sprintf (out, "\x0FE#%c%c", x, num); snprintf (out, sizeof(out), "\x0FE#%c%c", x, num);
write (fd, out, 4); write (fd, out, 4);
} }
@@ -848,7 +848,7 @@ MtxOrb_set_char (int n, char *dat)
if (!dat) if (!dat)
return; return;
sprintf (out, "\x0FEN%c", n); snprintf (out, sizeof(out), "\x0FEN%c", n);
write (fd, out, 3); write (fd, out, 3);
for (row = 0; row < MtxOrb->cellhgt; row++) { for (row = 0; row < MtxOrb->cellhgt; row++) {
@@ -919,12 +919,12 @@ MtxOrb_draw_frame (char *dat)
if (!dat) if (!dat)
return; return;
// sprintf(out, "%cG%c%c", 254, 1, 1); // snprintf(out, sizeof(out), "%cG%c%c", 254, 1, 1);
// write(fd, out, 4); // write(fd, out, 4);
// write(fd, dat, lcd.wid*lcd.hgt); // write(fd, dat, lcd.wid*lcd.hgt);
for (i = 0; i < MtxOrb->hgt; i++) { for (i = 0; i < MtxOrb->hgt; i++) {
sprintf (out, "\x0FEG\x001%c", i + 1); snprintf (out, sizeof(out), "\x0FEG\x001%c", i + 1);
write (fd, out, 4); write (fd, out, 4);
write (fd, dat + (MtxOrb->wid * i), MtxOrb->wid); write (fd, dat + (MtxOrb->wid * i), MtxOrb->wid);
} }
+1 -1
View File
@@ -669,7 +669,7 @@ void bayrad_set_char(int n, char *dat)
n = 0x40 + (n * 8); /* Set n to the proper location in CG RAM */ n = 0x40 + (n * 8); /* Set n to the proper location in CG RAM */
/* Set the LCD to accept data for rewrite-able char n */ /* Set the LCD to accept data for rewrite-able char n */
sprintf(out, "\x88%c", n); snprintf(out, sizeof(out), "\x88%c", n);
write(fd, out, 2); write(fd, out, 2);
for(row=0; row<lcd.cellhgt; row++) for(row=0; row<lcd.cellhgt; row++)
+2 -2
View File
@@ -675,7 +675,7 @@ void
HD44780_init_num () HD44780_init_num ()
{ {
char out[3]; char out[3];
sprintf (out, "%cn", 254); snprintf (out, sizeof(out), "%cn", 254);
//write(fd, out, 2); //write(fd, out, 2);
} }
@@ -686,7 +686,7 @@ void
HD44780_num (int x, int num) HD44780_num (int x, int num)
{ {
char out[5]; char out[5];
sprintf (out, "%c#%c%c", 254, x, num); snprintf (out, sizeof(out), "%c#%c%c", 254, x, num);
//write(fd, out, 4); //write(fd, out, 4);
} }
+11 -11
View File
@@ -253,7 +253,7 @@ void LB216_chr(int x, int y, char c)
//if(c < 32 && c >= 0) c += 128; //if(c < 32 && c >= 0) c += 128;
// lcd.framebuf[(y*lcd.wid) + x] = c; // lcd.framebuf[(y*lcd.wid) + x] = c;
char chr[1]; char chr[1];
sprintf(chr, "%c", c); snprintf (chr, sizeof(chr), "%c", c);
LB216_string (x, y, chr); LB216_string (x, y, chr);
} }
@@ -267,11 +267,11 @@ void LB216_backlight(int on)
char out[4]; char out[4];
if(on) if(on)
{ {
sprintf(out, "%c%c", 254, 253); snprintf (out, sizeof(out), "%c%c", 254, 253);
} }
else else
{ {
sprintf(out, "%c%c", 254, 252); snprintf (out, sizeof(out), "%c%c", 254, 252);
} }
write(fd, out, 2); write(fd, out, 2);
} }
@@ -283,7 +283,7 @@ void LB216_backlight(int on)
static void LB216_hidecursor() static void LB216_hidecursor()
{ {
char out[4]; char out[4];
sprintf(out, "%c%c", 254,12); snprintf (out, sizeof(out), "%c%c", 254,12);
write(fd, out, 2); write(fd, out, 2);
} }
@@ -293,7 +293,7 @@ static void LB216_hidecursor()
static void LB216_reboot() static void LB216_reboot()
{ {
char out[4]; char out[4];
sprintf(out, "%c%c", 254,1); snprintf (out, sizeof(out), "%c%c", 254,1);
write(fd, out, 2); write(fd, out, 2);
} }
@@ -310,18 +310,18 @@ void LB216_draw_frame(char *dat)
if(!dat) return; if(!dat) return;
sprintf(out, "%c%c", 254,80); snprintf (out, sizeof(out), "%c%c", 254,80);
write(fd, out, 2); write(fd, out, 2);
for(j=0; j<lcd.hgt; j++) { for(j=0; j<lcd.hgt; j++) {
if (j>=2) { if (j>=2) {
sprintf(out,"%c%c",254,148+(64*(j-2))); snprintf (out, sizeof(out),"%c%c",254,148+(64*(j-2)));
} else { } else {
sprintf(out,"%c%c",254,128+(64*(j))); snprintf (out, sizeof(out),"%c%c",254,128+(64*(j)));
} }
write(fd, out, 2); write(fd, out, 2);
for(i=0; i<lcd.wid; i++) { for(i=0; i<lcd.wid; i++) {
sprintf(out,"%c",dat[i+(j*lcd.wid)]); snprintf (out, sizeof(out),"%c",dat[i+(j*lcd.wid)]);
write(fd, out, 1); write(fd, out, 1);
} }
} }
@@ -558,7 +558,7 @@ void LB216_set_char(int n, char *dat)
n=64+(8*n); n=64+(8*n);
if(!dat) return; if(!dat) return;
sprintf(out, "%c%c", 254, n); snprintf (out, sizeof(out), "%c%c", 254, n);
write(fd, out, 2); write(fd, out, 2);
for(row=0; row<lcd.cellhgt; row++) for(row=0; row<lcd.cellhgt; row++)
@@ -569,7 +569,7 @@ void LB216_set_char(int n, char *dat)
letter <<= 1; letter <<= 1;
letter |= (dat[(row*lcd.cellwid) + col] > 0); letter |= (dat[(row*lcd.cellwid) + col] > 0);
} }
sprintf(out,"%c",letter); snprintf (out, sizeof(out),"%c",letter);
write(fd, out, 1); write(fd, out, 1);
} }
} }
+2 -2
View File
@@ -226,9 +226,9 @@ sli_flush_box (int lft, int top, int rgt, int bot)
/* I like having hex, everywhere and all the time */ /* I like having hex, everywhere and all the time */
for (y = top; y <= bot; y++) { for (y = top; y <= bot; y++) {
if (y == 1) if (y == 1)
sprintf (out, "%c%c", 0x0FE, 0x080 + lft); snprintf (out, sizeof(out), "%c%c", 0x0FE, 0x080 + lft);
if (y == 2) if (y == 2)
sprintf (out, "%c%c", 0x0FE, 0x0C0 + lft); snprintf (out, sizeof(out), "%c%c", 0x0FE, 0x0C0 + lft);
write (fd, out, 0x002); write (fd, out, 0x002);
write (fd, lcd.framebuf + (y * lcd.wid) + lft, rgt - lft + 1); write (fd, lcd.framebuf + (y * lcd.wid) + lft, rgt - lft + 1);
} }
+1 -1
View File
@@ -433,7 +433,7 @@ exit_program (int val)
case 1: strcat(buf, "SIGHUP"); break; case 1: strcat(buf, "SIGHUP"); break;
case 2: strcat(buf, "SIGINT"); break; case 2: strcat(buf, "SIGINT"); break;
case 15: strcat(buf, "SIGTERM"); break; case 15: strcat(buf, "SIGTERM"); break;
default: sprintf(buf, "server shutting down on signal %d", val); break; default: snprintf(buf, sizeof(buf), "server shutting down on signal %d", val); break;
// Other values should not be seen, but just in case.. // Other values should not be seen, but just in case..
} }