Fix assorted GCC warnings

This commit is contained in:
Juhani Krekelä 2021-04-20 16:07:27 +03:00
parent 77d8f2b28d
commit d5db35b861
21 changed files with 97 additions and 64 deletions

View File

@ -48,6 +48,7 @@ in this Software without prior written authorization from the X Consortium.
#include "port_before.h"
#include <stdio.h>
#include <stdint.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@ -401,7 +402,9 @@ XtPointer call_data;
{
WWWWidget rw = (WWWWidget)XtParent(widget);
register Widget child = rw->www.child;
int pix = (int)call_data;
// This is safe since we pass that data into here ourselves and it is
// originally of type int
int pix = (intptr_t)call_data;
Position x, y;
if (child == NULL) return; /* no child to scroll. */

View File

@ -199,7 +199,7 @@ BookmarkContext bc;
if ((fp = fopen(bc->filename, "w")) != NULL)
{
fprintf (fp, bc->header);
fprintf (fp, "%s", bc->header);
fprintf (fp, "\n");
for (g = (BGroup *)GListGetHead(bc->glist); g != NULL;
g = (BGroup *)GListGetNext(bc->glist))
@ -212,7 +212,7 @@ BookmarkContext bc;
}
fprintf (fp, "</ul>\n");
}
fprintf (fp, bc->footer);
fprintf (fp, "%s", bc->footer);
fprintf (fp, "\n");
fclose(fp);
}

View File

@ -21,6 +21,7 @@
#include "port_before.h"
#include <stdio.h>
#include <stdlib.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>

View File

@ -23,6 +23,7 @@
#include "port_before.h"
#include <stdio.h>
#include <limits.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@ -724,14 +725,18 @@ ChimeraRequest *lastresort;
int count;
MemPool mp;
ChimeraRequest *wr = NULL;
char base_url[255];
char base_url[PATH_MAX + 6];
/*
* Default base URL; this allows filenames to be used on the
* command line
*/
strcpy( base_url, "file:" ) ;
getcwd( base_url + 5, sizeof(base_url) - 5 ) ;
if (getcwd( base_url + 5, sizeof(base_url) - 5 ) == NULL) {
perror("getcwd failed");
// Try using just the root of filesystem if we could not get cwd
strcat( base_url, "/" ) ;
}
strcat( base_url, "/" ) ;
ChimeraAddReference(cres);
@ -815,7 +820,7 @@ ChimeraRequest *lastresort;
wr = RequestCreate(wc->cres, "file:/", NULL);
}
myassert(wr != NULL, "ERROR: No valud URLs found for new head.\n");
myassert(wr != NULL, "ERROR: No valid URLs found for new head.\n");
StackOpen(wc->tstack, wr);

View File

@ -366,9 +366,7 @@ ChimeraResources cres;
ChimeraStream ps;
int s;
struct sockaddr_in6 addr;
struct hostent *hp;
int namlen;
char host[BUFSIZ];
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s < 0) return(NULL);

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include <signal.h>
#include <limits.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@ -54,12 +55,12 @@ extern char *fallback_resources[];
static ChimeraResources globalcres;
void
int
main(argc, argv)
int argc;
char **argv;
{
char base_url[255];
char base_url[PATH_MAX + 6];
signal(SIGINT, sigigh_handler);
signal(SIGQUIT, sigigh_handler);
@ -76,7 +77,10 @@ char **argv;
* command line
*/
strcpy( base_url, "file:" ) ;
getcwd( base_url + 5, sizeof(base_url) - 5 ) ;
if (getcwd( base_url + 5, sizeof(base_url) - 5 ) == NULL) {
perror("getcwd failed");
return 1;
}
strcat( base_url, "/" ) ;
if (argc > 1) HeadCreate(globalcres,
@ -88,6 +92,8 @@ char **argv;
* And away we go...
*/
XtAppMainLoop(globalcres->appcon);
return 0;
}
/*

View File

@ -374,7 +374,6 @@ ChimeraResources cres;
ChimeraRequest *wr;
{
ChimeraSource ws;
char *content;
/*
* Input data can make the output different everytime don't even

View File

@ -399,7 +399,14 @@ void *closure;
cs->wp, rh, NULL, NULL, u->state,
cs->rap, cs->rapc)) == NULL)
{
DownloadOpen(cs->wc->cres, wr);
if ((wr = RequestCreate(cs->wc->cres, url, NULL)) == NULL)
{
HeadPrintMessage(cs->wc, "Invalid URL.");
}
else
{
DownloadOpen(cs->wc->cres, wr);
}
SinkDestroy(wp);
return(-1);
}

View File

@ -19,6 +19,7 @@
*/
#include "port_before.h"
#include <assert.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
@ -157,7 +158,23 @@ void *closure;
strcat(final, "; rm ");
strcat(final, filename);
strcat(final, ") &");
system(final);
int status = system(final);
if (status == -1)
{
perror("system");
}
else if (status != 0)
{
assert(WIFEXITED(status) || WIFSIGNALED(status));
if (WIFEXITED(status))
{
fprintf(stderr, "Cleanup failed, return code %i\n", WEXITSTATUS(status));
}
else if(WIFSIGNALED(status))
{
fprintf(stderr, "Cleanup failed, child died from signal %i\n", WTERMSIG(status));
}
}
}
ViewDestroy(vi);
@ -285,7 +302,7 @@ ViewInfo *vi;
box = XtCreateManagedWidget("box2", boxWidgetClass, paned, NULL, 0);
stop = XtVaCreateManagedWidget("stop", commandWidgetClass, box, NULL, 0);
stop = XtCreateManagedWidget("stop", commandWidgetClass, box, NULL, 0);
XtAddCallback(stop, XtNcallback, ViewDialogStop, vi);

View File

@ -21,6 +21,7 @@
#include "port_before.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>

View File

@ -87,24 +87,20 @@ StartReaper()
* PipeCommand
*
* fork and exec to get a program running and supply it with
* a stdin, stdout, stderr that so we can talk to it.
* a stdin so that we can talk to it.
* ^ Used to supply stdout/stderr too, but that was commented out before
* I got here -nortti, 2021
*/
int
PipeCommand(command, fd)
char *command;
int *fd;
{
int pout[2];
int pin[2];
int pid;
/*
if (pipe(pout) == -1) return(-1);
*/
if (pipe(pin) == -1)
{
close(pout[0]);
close(pout[1]);
return(-1);
}
@ -115,13 +111,6 @@ int *fd;
}
else if (pid == 0)
{
/*
if (pout[1] != 1)
{
dup2(pout[1], 1);
close(pout[1]);
}
*/
if (pin[0] != 0)
{
dup2(pin[0], 0);
@ -134,14 +123,10 @@ int *fd;
}
else
{
close(pout[1]);
close(pin[0]);
}
fd[0] = pin[1];
/*
fd[1] = pout[0];
*/
return(0);
}

View File

@ -554,7 +554,6 @@ InputType type;
int width, height;
XFontStruct *font;
char *value;
HTMLBox box;
InputState *ci;
Boolean echo;
char *name;
@ -601,7 +600,7 @@ InputType type;
/* End: replaces "width = 100;" */
ci = CreateInputState(fs, p, type);
box = CreateInputBox(fs->li, env, ci, width, height);
CreateInputBox(fs->li, env, ci, width, height);
ci->w = w;
return;
@ -618,7 +617,6 @@ MLElement p;
{
Widget w;
Boolean state;
HTMLBox box;
InputState *ci;
if (MLFindAttribute(p, "checked") != NULL) state = True;
@ -631,7 +629,7 @@ MLElement p;
NULL);
ci = CreateInputState(fs, p, INPUT_CHECKBOX);
box = CreateInputBox(fs->li, env, ci, 15, 15);
CreateInputBox(fs->li, env, ci, 15, 15);
ci->w = w;
return;
@ -650,7 +648,6 @@ MLElement p;
Boolean state;
char *name;
InputState *ci, *peer;
HTMLBox box;
if (MLFindAttribute(p, "checked") != NULL) state = True;
else state = False;
@ -671,7 +668,7 @@ MLElement p;
NULL);
ci = CreateInputState(fs, p, INPUT_RADIO);
box = CreateInputBox(fs->li, env, ci, 15, 15);
CreateInputBox(fs->li, env, ci, 15, 15);
ci->w = w;
ci->name = (char *)MPStrDup(fs->li->mp, name);
@ -703,7 +700,6 @@ InputType type;
Widget w;
InputState *ci;
char *name;
HTMLBox box;
argcnt = 0;
name = type == INPUT_SUBMIT ? "submit":"reset";
@ -731,7 +727,7 @@ InputType type;
height = font->ascent + font->descent + 3;
}
ci = CreateInputState(fs, p, type);
box = CreateInputBox(fs->li, env, ci, width, height);
CreateInputBox(fs->li, env, ci, width, height);
ci->w = w;
if (type == INPUT_SUBMIT)
@ -848,7 +844,6 @@ MLElement p;
XFontStruct *font;
int rows, cols;
Widget w;
HTMLBox box;
HTMLObject obj;
if ((fenv = HTMLGetIDEnv(env, TAG_FORM)) == NULL) return;
@ -878,7 +873,7 @@ MLElement p;
width *= cols;
ci = CreateInputState(fs, obj->o.p, INPUT_TEXTAREA);
box = CreateInputBox(fs->li, env, ci, width, height);
CreateInputBox(fs->li, env, ci, width, height);
ci->w = w;
return;
@ -903,7 +898,6 @@ HTMLEnv env;
int width, twidth;
XFontStruct *font;
Widget w, smw;
HTMLBox box;
OptionState *c;
GList oplist = fs->oplist;
HTMLObject obj;
@ -949,8 +943,8 @@ HTMLEnv env;
obj = (HTMLObject)GListGetHead(env->slist);
ci = CreateInputState(fs, obj->o.p, INPUT_SELECT);
box = CreateInputBox(fs->li, env, ci,
width + 10, font->ascent + font->descent + 4);
CreateInputBox(fs->li, env, ci,
width + 10, font->ascent + font->descent + 4);
ci->w = w;
ci->oplist = oplist;
@ -1084,6 +1078,9 @@ MLElement p;
if ((url = MLFindAttribute(p, "src")) == NULL) return;
ci = CreateInputState(fs, p, INPUT_IMAGE);
ci->img = HTMLCreateInline(fs->li, env, url, &ii, &orh, ci);
memset(&ii, 0, sizeof(ii));
ii.p = p;
ii.closure = ci;
@ -1092,8 +1089,5 @@ MLElement p;
orh.select = FormImageSelectCallback;
orh.motion = FormImageMotionCallback;
ci = CreateInputState(fs, p, INPUT_IMAGE);
ci->img = HTMLCreateInline(fs->li, env, url, &ii, &orh, ci);
return;
}

View File

@ -477,7 +477,7 @@ ChimeraResources cres;
char *cssfile;
char *b;
struct stat st;
size_t rval, blen;
size_t rval, blen=0;
mp = MPCreate();
lc = (HTMLClass)MPCGet(mp, sizeof(struct HTMLClassP));

View File

@ -354,9 +354,9 @@ MLElement p;
char *value, *cp;
int x;
int border;
unsigned int width, maxwidth;
unsigned int width;
maxwidth = width = HTMLGetMaxWidth(li, env->penv);
width = HTMLGetMaxWidth(li, env->penv);
env->ff = FLOW_LEFT_JUSTIFY;
env->anchor = NULL;

View File

@ -40,6 +40,7 @@
#include "port_before.h"
#include <assert.h>
#include <stdlib.h>
#include "port_after.h"
@ -472,7 +473,12 @@ ccf_create_gray_conversion_table(cct_cube cube)
{
int j;
int min_dist = 400000; /* big number ! */
int min_entry;
// GCC complains about min_entry possibly not being set in the loop
// I'm not able to prove that it does, so set up a sentinel value and
// assert on it
// cube->u.grayscale.pixel_values is defined as pixel_values[256], so
// min_entry can never be 256 if it is a valid index
int min_entry = 256;
for (j = 0; j < cube->u.grayscale.value_count; j++)
{
int dist;
@ -484,6 +490,7 @@ ccf_create_gray_conversion_table(cct_cube cube)
min_entry = j;
}
}
assert(min_entry != 256);
answer->pixel_values[i] = cube->u.grayscale.pixel_values[min_entry];
}
return answer;

View File

@ -1060,7 +1060,6 @@ void *state; /* ignored */
ImageState *is;
int format;
XWindowAttributes xwa;
int status;
char *content;
int i;
ChimeraSink wp;
@ -1088,7 +1087,7 @@ void *state; /* ignored */
if (!ic->init) ImageClassInit(ic, is->dpy);
status = XGetWindowAttributes(is->dpy, is->win, &xwa);
XGetWindowAttributes(is->dpy, is->win, &xwa);
is->v = xwa.visual;
is->depth = xwa.depth;
is->cmap = xwa.colormap;

View File

@ -5,6 +5,7 @@
#include "port_before.h"
#include <png.h>
#include <string.h>
#include "port_after.h"

View File

@ -32,6 +32,7 @@
#include "imagep.h"
#include "xbmp.h"
#ifdef CHIMERA_BIG_ENDIAN
static byte lc_reverse_byte[] =
{
0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240,
@ -50,6 +51,7 @@ static byte lc_reverse_byte[] =
11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251,
7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247,
15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255};
#endif
/*
* xbmGetImage

View File

@ -450,7 +450,7 @@ xccf_allocate_special(
int r = intensities[0] >> 8;
int g = intensities[1] >> 8;
int b = intensities[2] >> 8;
int gr;
//int gr;
if(really_allocated_return) *really_allocated_return = false;
if(cube)
{
@ -489,7 +489,7 @@ xccf_allocate_special(
break;
}
}
gr = (r + g + b) / 3;
//gr = (r + g + b) / 3;
if(grayscale /* && xccf_color_compare(r,g,b,gr,gr,gr)*/)
{
for(i = 0; i < grayscale->u.grayscale.value_count; i++)

View File

@ -29,6 +29,8 @@
#include <X11/Xatom.h>
#include <X11/Xmu/Xmu.h>
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
@ -943,12 +945,14 @@ ConvertSelection(Widget aw, Atom * selection, Atom * target, Atom * type,
XSelectionRequestEvent *req = XtGetSelectionRequest(aw, *selection, NULL);
if (*target == XA_TARGETS(XtDisplay(aw))) {
Atom *targetP, *std_targets;
Atom *targetP;
char *std_targets;
unsigned long std_length;
XmuConvertStandardSelection(aw, req->time, selection,
target, type, &std_targets,
&std_length, format);
assert(*format == sizeof(Atom) * 8);
*value = XtMalloc((unsigned) sizeof(Atom) * (std_length + 1));
targetP = *(Atom **) value;
@ -1027,7 +1031,8 @@ RequestSelection(Widget aw, XtPointer client, Atom * selection, Atom * type,
ClearHighlight(w);
savex = w->text.OldCursorX;
w->text.CursorPos = (int) client;
// This is safe because we passed this in as an int
w->text.CursorPos = (intptr_t) client;
#ifdef DEBUG_TF
printf("RequestSelection: inserting %s length=%d at pos: %d\n",
(char *) value, (int) (*length), w->text.CursorPos);
@ -1052,9 +1057,11 @@ InsertSelection(Widget aw, XEvent * event, String * params, Cardinal * num_param
#ifdef DEBUG_TF
printf("InsertSelection: event at pos: %d\n", pos);
#endif
// The cast to intptr_t assumes that pointers are at least as wide as
// ints are, which is pretty safe assumption
XtGetSelectionValue(aw, XA_PRIMARY, XA_STRING,
RequestSelection,
(XtPointer) pos, event->xbutton.time);
(XtPointer) (intptr_t)pos, event->xbutton.time);
}

View File

@ -354,7 +354,6 @@ ssize_t *len;
const char *authfield = "Authorization: ";
char *username;
char *password;
URLParts *up;
if (hi->hp == NULL) return(NULL);
if (hi->hp->type == NULL || strcasecmp(hi->hp->type, "basic") != 0)
@ -364,7 +363,6 @@ ssize_t *len;
username = hi->hp->username;
password = hi->hp->password;
up = hi->up;
line = (char *)MPGet(hi->rmp,
strlen(authfield) +
@ -920,13 +918,16 @@ HTTPInfo **hip;
{
HTTPAuthCallback(hip, hi->up->username,
hi->up->password);
username = NULL;
}
else username = hi->up->username;
}
else username = "";
hi->wa = AuthCreate(hi->cres, "Enter password", username,
HTTPAuthCallback, hip);
if (username != NULL) {
hi->wa = AuthCreate(hi->cres, "Enter password", username,
HTTPAuthCallback, hip);
}
/*
* If the authorization context is created then return -1 to