Browse Source

Suppress some compiler warnings

pre-master-46
Holger Vogt 5 years ago
parent
commit
238f8d393a
  1. 10
      src/frontend/plotting/x11.c
  2. 2
      src/misc/string.c

10
src/frontend/plotting/x11.c

@ -133,6 +133,8 @@ static void resize(Widget w, XtPointer client_data, XEvent *ev, Boolean *continu
static void hardcopy(Widget w, XtPointer client_data, XtPointer call_data); static void hardcopy(Widget w, XtPointer client_data, XtPointer call_data);
static void killwin(Widget w, XtPointer client_data, XtPointer call_data); static void killwin(Widget w, XtPointer client_data, XtPointer call_data);
int X11_GetLenStr(GRAPH* gr, char* instring);
static int static int
errorhandler(Display *display, XErrorEvent *errorev) errorhandler(Display *display, XErrorEvent *errorev)
@ -739,7 +741,7 @@ X11_Text(const char *text, int x, int y, int angle)
if (angle == 0) { if (angle == 0) {
XftDrawStringUtf8( XftDrawStringUtf8(
DEVDEP(currentgraph).draw, &DEVDEP(currentgraph).color, DEVDEP(currentgraph).font0, DEVDEP(currentgraph).draw, &DEVDEP(currentgraph).color, DEVDEP(currentgraph).font0,
x, currentgraph->absolute.height - y, (FcChar8*)text, strlen(text));
x, currentgraph->absolute.height - y, (FcChar8*)text, (int)strlen(text));
} }
else if (angle == 90) { else if (angle == 90) {
int wlen=0, wheight; int wlen=0, wheight;
@ -748,7 +750,7 @@ X11_Text(const char *text, int x, int y, int angle)
XftDrawStringUtf8( XftDrawStringUtf8(
DEVDEP(currentgraph).draw, &DEVDEP(currentgraph).color, DEVDEP(currentgraph).font90, DEVDEP(currentgraph).draw, &DEVDEP(currentgraph).color, DEVDEP(currentgraph).font90,
x + (int)(1.5 * wlen), currentgraph->absolute.height - y + (int)(0.5 * wheight), (FcChar8*)text, strlen(text));
x + (int)(1.5 * wlen), currentgraph->absolute.height - y + (int)(0.5 * wheight), (FcChar8*)text, (int)strlen(text));
} }
else else
fprintf(stderr, " Xft: angles other than 0 or 90 are not supported in ngspice\n"); fprintf(stderr, " Xft: angles other than 0 or 90 are not supported in ngspice\n");
@ -1063,7 +1065,7 @@ zoomin(GRAPH *graph)
SWAP(double, fy0, fy1); SWAP(double, fy0, fy1);
} }
strncpy(buf2, graph->plotname, sizeof(buf2));
strncpy(buf2, graph->plotname, sizeof(buf2) - 1);
if ((t = strchr(buf2, ':')) != NULL) if ((t = strchr(buf2, ':')) != NULL)
*t = '\0'; *t = '\0';
@ -1378,7 +1380,7 @@ Xget_str_length(const char *text, int* wlen, int* wheight, XftFont* gfont, char*
XftPatternDestroy(ext_pat); XftPatternDestroy(ext_pat);
} }
if(gfont) if(gfont)
XftTextExtentsUtf8( display, gfont, (XftChar8 *)text, strlen(text), &extents );
XftTextExtentsUtf8( display, gfont, (XftChar8 *)text, (int)strlen(text), &extents );
else { else {
return 1; return 1;
} }

2
src/misc/string.c

@ -76,7 +76,7 @@ char *dup_string(const char *str, size_t n_char)
char *p; char *p;
if ((p = TMALLOC(char, n_char + 1)) != NULL) { if ((p = TMALLOC(char, n_char + 1)) != NULL) {
(void) strncpy(p, str, n_char);
(void) strncpy(p, str, n_char + 1);
p[n_char] = '\0'; p[n_char] = '\0';
} }
return p; return p;

Loading…
Cancel
Save