[prev in list] [next in list] [prev in thread] [next in thread]
List: gpsd-commit-watch
Subject: [Gpsd-commit-watch] r2578 - trunk
From: esr () sheep ! berlios ! de (Eric S ! Raymond at BerliOS)
Date: 2005-05-30 9:07:50
Message-ID: 200505300907.j4U97oWD010342 () sheep ! berlios ! de
[Download RAW message or body]
Author: esr
Date: 2005-05-30 11:07:47 +0200 (Mon, 30 May 2005)
New Revision: 2578
Modified:
trunk/Tachometer.c
trunk/display.c
trunk/geoid.c
trunk/libgps.c
trunk/libgpsd_core.c
trunk/tsip.c
trunk/xgps.c
trunk/xgpsspeed.c
Log:
236 splint warnings.
Modified: trunk/Tachometer.c
===================================================================
--- trunk/Tachometer.c 2005-05-29 14:44:04 UTC (rev 2577)
+++ trunk/Tachometer.c 2005-05-30 09:07:47 UTC (rev 2578)
@@ -19,7 +19,7 @@
#include <math.h>
#include "config.h" /* must define UNUSED */
-#define D2R 0.0174532925199432957692369076848861271L /* radians = pi/180 */
+#define D2R 0.0174532925199432957692369076848861271 /* radians = pi/180 */
/****************************************************************
*
@@ -59,6 +59,7 @@
{-10, 0,-10,-10},
{-10, 0, 10, 0}};
+/*@ -initallelements @*/
/* " X 10 %" character database */
static StringRec char_data[] = {
{ 2, /* "X" */
@@ -94,8 +95,10 @@
{24, 5},
{24, 2}}}};
#endif
+/*@ -initallelements @*/
/*@ -charint @*/
+/*@ -nullderef -immediatetrans -type -nullassign @*/
#define offst(field) XtOffset(TachometerWidget, field)
static XtResource resources[] = {
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
@@ -117,6 +120,7 @@
{XtNinternalBorderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
offst(tachometer.internal_border), XtRImmediate, (caddr_t) 0},
};
+/*@ -nullderef -immediatetrans +type +nullassign @*/
static void Initialize(Widget request, Widget new),
Realize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes),
@@ -124,6 +128,7 @@
Destroy(Widget w);
static Boolean SetValues(Widget current, Widget request UNUSED, Widget new);
+/*@ -fullinitblock @*/
TachometerClassRec tachometerClassRec = {
{
/* core_class fields */
@@ -167,6 +172,7 @@
}
};
+/*@ +fullinitblock @*/
WidgetClass tachometerWidgetClass = (WidgetClass)&tachometerClassRec;
/* Private procedures */
@@ -175,6 +181,7 @@
Display *d, Drawable w, GC gc,
Cardinal center_x, Cardinal center_y, Cardinal radius_x, Cardinal radius_y)
{
+ /*@ -compdef @*/
XPoint points[360];
Cardinal angle;
@@ -185,19 +192,20 @@
(double) radius_y + (double) center_y);
}
(void)XFillPolygon(d, w, gc, points, 360, Complex, CoordModeOrigin);
+ /*@ +compdef @*/
}
static void DrawSingleNumber(TachometerWidget w, int which, Cardinal x, Cardinal y)
{
XSegment segments[7];
- Cardinal nsegments, width, height;
- unsigned char count;
+ Cardinal nsegments, width, height, count;
- width = (w->core.width / 2) - w->tachometer.internal_border;
- height = (w->core.height / 2) - w->tachometer.internal_border;
- if ((width <= 0) || (height <= 0))
+ width = (Cardinal)((w->core.width / 2) - w->tachometer.internal_border);
+ height = (Cardinal)((w->core.height / 2) - w->tachometer.internal_border);
+ if ((width == 0) || (height == 0))
return;
+ /*@ +charint -compdef */
for (count = 0, nsegments = 0; count < 7; count++)
if (num_segment[which].digit[count] == 1) {
segments[nsegments].x1 = (short)
@@ -212,7 +220,8 @@
}
(void)XDrawSegments(XtDisplay(w), XtWindow(w),
- w->tachometer.scale_GC, segments, nsegments);
+ w->tachometer.scale_GC, segments, (int)nsegments);
+ /*@ -charint +compdef */
}
static void DrawNumbers(TachometerWidget w, int which, Cardinal x, Cardinal y)
@@ -226,32 +235,35 @@
static void DrawLabelString(TachometerWidget w)
{
- XPoint points[5];
- unsigned char char_count, data_count;
+ XPoint points[5];
+ int char_count, data_count;
Cardinal ry, center_x, center_y, radius_x, radius_y;
GC gc;
- center_x = w->core.width / 2; center_y = w->core.height / 2;
+ center_x = (Cardinal)(w->core.width / 2);
+ center_y = (Cardinal)(w->core.height / 2);
radius_x = center_x - w->tachometer.internal_border;
radius_y = center_y - w->tachometer.internal_border;
- if (!(center_x && center_y && (radius_x > 0) && (radius_y > 0)))
+ if (!(center_x != 0 && center_y != 0 && (radius_x > 0) && (radius_y > 0)))
return;
- ry = (double) radius_y * 0.35 + center_y;
+ ry = (Cardinal)(radius_y * 0.35 + center_y);
gc = w->tachometer.scale_GC;
+ /*@ -compdef @*/
for (char_count = 0; char_count < 4; char_count++) {
for (data_count = 0; data_count < char_data[char_count].nofline
; data_count++) {
- points[data_count].x = (double)
- (char_data[char_count].point_list[data_count].x) *
- (double) radius_x * 0.01 + center_x;
- points[data_count].y = (double)
- (char_data[char_count].point_list[data_count].y) *
- (double) radius_y * 0.01 + ry;
+ points[data_count].x = (short)
+ ((char_data[char_count].point_list[data_count].x) *
+ (double) radius_x * 0.01 + center_x);
+ points[data_count].y = (short)
+ ((char_data[char_count].point_list[data_count].y) *
+ (double) radius_y * 0.01 + ry);
}
- XDrawLines(XtDisplay(w), XtWindow(w), gc, points,
+ (void)XDrawLines(XtDisplay(w), XtWindow(w), gc, points,
char_data[char_count].nofline, CoordModeOrigin);
}
+ /*@ +compdef @*/
}
static void DrawGauge(TachometerWidget w)
@@ -262,6 +274,7 @@
GC gc;
double step, jump = 1.0;
+ /*@ -type -unsignedcompare -compdef @*/
center_x = w->core.width / 2; center_y = w->core.height / 2;
radius_x = center_x - w->tachometer.internal_border;
radius_y = center_y - w->tachometer.internal_border;
@@ -297,6 +310,7 @@
in_gauge_y, out_gauge_x, out_gauge_y);
}
}
+ /*@ +type +unsignedcompare +compdef @*/
DrawLabelString(w);
}
@@ -307,6 +321,7 @@
double cur_theta1, cur_theta2, cur_theta3, cur_theta4, cur_theta5;
Cardinal center_x, center_y, radius_x, radius_y;
+ /*@ -type -unsignedcompare -compdef @*/
center_x = w->core.width / 2; center_y = w->core.height / 2;
radius_x = center_x - w->tachometer.internal_border;
radius_y = center_y - w->tachometer.internal_border;
@@ -329,17 +344,21 @@
points[3].y = (short)(cos(cur_theta5) * radius_y * 0.1 + center_y);
points[4].x = (short)(sin(cur_theta3) * radius_x * 0.7 + center_x);
points[4].y = (short)(cos(cur_theta3) * radius_y * 0.7 + center_y);
+ /*@ -usedef @*/
points[5].x = points[0].x;
points[5].y = points[0].y;
+ /*@ +usedef @*/
(void)XDrawLines(XtDisplay(w), XtWindow(w),
w->tachometer.needle_GC, points, 6, CoordModeOrigin);
+ /*@ +type +unsignedcompare +compdef @*/
}
static void DrawTachometer(TachometerWidget w)
{
Cardinal center_x, center_y, radius_x, radius_y;
+ /*@ -type -unsignedcompare -compdef @*/
center_x = w->core.width / 2; center_y = w->core.height / 2;
radius_x = center_x - w->tachometer.internal_border;
radius_y = center_y - w->tachometer.internal_border;
@@ -360,6 +379,7 @@
/* Draw the details */
DrawGauge(w);
DrawNeedle(w, w->tachometer.value);
+ /*@ +type +unsignedcompare +compdef @*/
}
static void MoveNeedle(TachometerWidget w, int new)
@@ -376,6 +396,7 @@
else
step = (w->tachometer.speed ? -w->tachometer.speed : new - old);
+ /*@ -usedef @*/
if (old < new) {
for (loop = old; loop < new; loop += step)
DrawNeedle(w, loop);
@@ -390,6 +411,7 @@
if (loop != new + step) /* The final needle wasn't printed */
DrawNeedle(w, new);
+ /*@ +usedef @*/
w->tachometer.value = new;
}
@@ -401,10 +423,12 @@
values.background = ta->core.background_pixel;
values.foreground = ta->tachometer.needle ^ ta->core.background_pixel;
values.function = GXxor;
+ /*@ -type -compdef -mustfreeonly @*/
ta->tachometer.needle_GC = XtGetGC(
(Widget)ta,
(unsigned) GCFunction | GCBackground | GCForeground,
&values);
+ /*@ +type +compdef +mustfreeonly @*/
}
static void GetscaleGC(TachometerWidget ta)
@@ -413,10 +437,12 @@
values.foreground = ta->tachometer.scale;
values.background = ta->core.background_pixel;
+ /*@ -type -compdef -mustfreeonly @*/
ta->tachometer.scale_GC = XtGetGC(
(Widget)ta,
(unsigned) GCForeground | GCBackground,
&values);
+ /*@ +type +compdef +mustfreeonly @*/
}
static void GetcircleGC(TachometerWidget ta)
@@ -425,10 +451,12 @@
values.foreground = ta->tachometer.circle;
values.background = ta->core.background_pixel;
+ /*@ -type -compdef -mustfreeonly @*/
ta->tachometer.circle_GC = XtGetGC(
(Widget)ta,
(unsigned) GCForeground | GCBackground,
&values);
+ /*@ +type +compdef +mustfreeonly @*/
}
static void GetbackgroundGC(TachometerWidget ta)
@@ -437,10 +465,12 @@
values.foreground = ta->core.background_pixel;
values.background = ta->core.background_pixel;
+ /*@ -type -compdef -mustfreeonly @*/
ta->tachometer.background_GC = XtGetGC(
(Widget)ta,
(unsigned) GCForeground | GCBackground,
&values);
+ /*@ +type +compdef +mustfreeonly @*/
}
static void Initialize(Widget request UNUSED, Widget new)
@@ -492,7 +522,8 @@
static Boolean SetValues(Widget current, Widget request UNUSED, Widget new)
/* Set specified arguments into widget */
{
- Boolean back, changed = False;
+ /*@ -type -boolops -predboolothers @*/
+ Boolean back, changed = (Boolean)False;
TachometerWidget curta = (TachometerWidget) current;
TachometerWidget newta = (TachometerWidget) new;
@@ -522,6 +553,7 @@
MoveNeedle(newta, newta->tachometer.value);
changed = True;
}
+ /*@ +type +boolops +predboolothers @*/
return(changed);
}
Modified: trunk/display.c
===================================================================
--- trunk/display.c 2005-05-29 14:44:04 UTC (rev 2577)
+++ trunk/display.c 2005-05-30 09:07:47 UTC (rev 2578)
@@ -16,6 +16,7 @@
static int diameter;
static Pixmap pixmap;
+/*@ -usedef -compdef -mustfreefresh @*/
static void set_color(String color)
{
Display *dpy = XtDisplay(draww);
@@ -31,6 +32,7 @@
}
(void)XSetForeground(dpy, drawGC, col.pixel);
}
+/*@ +usedef @*/
void register_canvas(Widget w, GC gc)
{
@@ -46,7 +48,8 @@
diameter = min(width, height) - RM;
}
-static void pol2cart(double azimuth, double elevation, int *xout, int *yout)
+static void pol2cart(double azimuth, double elevation,
+ /*@out@*/int *xout, /*@out@*/int *yout)
{
azimuth *= DEG_2_RAD;
#ifdef PCORRECT
@@ -65,6 +68,7 @@
diam, diam, /* width, height */
0, 360 * 64); /* angle1, angle2 */
}
+/*@ +compdef @*/
void draw_graphics(struct gps_data_t *gpsdata)
{
@@ -72,7 +76,7 @@
char buf[20];
if (gpsdata->satellites != 0) {
- i = min(width, height);
+ i = (int)min(width, height);
set_color("White");
(void)XFillRectangle(XtDisplay(draww),pixmap,drawGC,0,0,width,height);
@@ -83,13 +87,15 @@
/* draw the 45 degree circle */
#ifdef PCORRECT
- draw_arc(width / 2, height / 2, (i - RM) * 0.7); /* sin(45) ~ 0.7 */
+#define FF 0.7 /* sin(45) ~ 0.7 */
#else
- draw_arc(width / 2, height / 2, (i - RM) * 0.5);
+#define FF 0.5
#endif
+ draw_arc(width / 2, height / 2, (unsigned)((i - RM) * FF));
+#undef FF
set_color("Black");
- draw_arc(width / 2, height / 2, i - RM);
+ draw_arc(width / 2, height / 2, (unsigned)(i - RM));
pol2cart(0, 0, &x, &y);
set_color("Black");
@@ -106,7 +112,9 @@
/* Now draw the satellites... */
for (i = 0; i < gpsdata->satellites; i++) {
- pol2cart(gpsdata->azimuth[i], gpsdata->elevation[i], &x, &y);
+ pol2cart((double)gpsdata->azimuth[i],
+ (double)gpsdata->elevation[i],
+ &x, &y);
if (gpsdata->ss[i] < 20)
set_color("Grey");
@@ -114,7 +122,7 @@
set_color("Yellow");
else
set_color("Green");
- XFillArc(XtDisplay(draww), pixmap, drawGC,
+ (void)XFillArc(XtDisplay(draww), pixmap, drawGC,
x - 5, y - 5, /* x,y */
11, 11, /* width, height */
0, 360 * 64 /* angle1, angle2 */
@@ -124,11 +132,11 @@
(void)XDrawString(XtDisplay(draww), pixmap, drawGC, x, y + 17, buf, 2);
if (gpsdata->ss[i]) {
set_color("Black");
- XDrawPoint(XtDisplay(draww), pixmap, drawGC, x, y);
+ (void)XDrawPoint(XtDisplay(draww), pixmap, drawGC, x, y);
}
}
- XCopyArea(XtDisplay(draww), pixmap, XtWindow(draww), drawGC,
+ (void)XCopyArea(XtDisplay(draww), pixmap, XtWindow(draww), drawGC,
0, 0, width, height, 0, 0);
}
}
@@ -138,6 +146,8 @@
{
(void)XCopyArea(XtDisplay(draww), pixmap, XtWindow(draww), drawGC,
cbs->event->xexpose.x, cbs->event->xexpose.y,
- cbs->event->xexpose.width, cbs->event->xexpose.height,
+ (unsigned int)cbs->event->xexpose.width,
+ (unsigned int)cbs->event->xexpose.height,
cbs->event->xexpose.x, cbs->event->xexpose.y);
}
+/*@ +mustfreefresh @*/
Modified: trunk/geoid.c
===================================================================
--- trunk/geoid.c 2005-05-29 14:44:04 UTC (rev 2577)
+++ trunk/geoid.c 2005-05-30 09:07:47 UTC (rev 2578)
@@ -64,8 +64,10 @@
ilon1*10.-180.,ilat1*10.-90.,
ilon2*10.-180.,ilat2*10.-90.,
lon, lat,
- geoid_delta[ilon1+ilat1*GEOID_COL], geoid_delta[ilon2+ilat1*GEOID_COL],
- geoid_delta[ilon1+ilat2*GEOID_COL], geoid_delta[ilon2+ilat2*GEOID_COL]
+ (double)geoid_delta[ilon1+ilat1*GEOID_COL],
+ (double)geoid_delta[ilon2+ilat1*GEOID_COL],
+ (double)geoid_delta[ilon1+ilat2*GEOID_COL],
+ (double)geoid_delta[ilon2+ilat2*GEOID_COL]
);
}
Modified: trunk/libgps.c
===================================================================
--- trunk/libgps.c 2005-05-29 14:44:04 UTC (rev 2577)
+++ trunk/libgps.c 2005-05-30 09:07:47 UTC (rev 2578)
@@ -85,7 +85,7 @@
fixp->epc = UNCERTAINTY_NOT_VALID;
}
-struct gps_data_t *gps_open(const char *host, const char *port)
+struct gps_data_t *gps_open(/*@null@*/const char *host, /*@null@*/const char *port)
/* open a connection to a gpsd daemon */
{
struct gps_data_t *gpsdata = (struct gps_data_t *)calloc(sizeof(struct \
gps_data_t), 1); @@ -440,7 +440,7 @@
/* wait for and read data being streamed from the daemon */
{
char buf[BUFSIZ];
- int n;
+ ssize_t n;
double received = 0;
/* the daemon makes sure that every read is NUL-terminated */
Modified: trunk/libgpsd_core.c
===================================================================
--- trunk/libgpsd_core.c 2005-05-29 14:44:04 UTC (rev 2577)
+++ trunk/libgpsd_core.c 2005-05-30 09:07:47 UTC (rev 2578)
@@ -106,7 +106,7 @@
static void *gpsd_ppsmonitor(void *arg)
{
struct gps_device_t *session = (struct gps_device_t *)arg;
- int cycle,duration, state;
+ int cycle,duration, state = 0;
struct timeval tv;
struct timeval pulse[2] = {{0,0},{0,0}};
@@ -197,7 +197,7 @@
{
session->packet_full = 0;
session->gpsdata.sentence_time = 0;
- session->gpsdata.sentence_length = session->outbuflen;
+ session->gpsdata.sentence_length = (int)session->outbuflen;
session->gpsdata.d_recv_time = timestamp();
session->gpsdata.set = ONLINE_SET | session->device_type->parse_packet(session);
@@ -245,7 +245,7 @@
double t = session->gpsdata.fix.time-session->lastfix.time;
double e = session->lastfix.eph + session->gpsdata.fix.eph;
session->gpsdata.fix.eps = e/t;
- if (session->gpsdata.fix.eps)
+ if (session->gpsdata.fix.eps != UNCERTAINTY_NOT_VALID)
session->gpsdata.set |= SPEEDERR_SET;
}
}
@@ -257,7 +257,7 @@
double e = session->lastfix.epv + session->gpsdata.fix.epv;
/* if vertical uncertainties are zero this will be too */
session->gpsdata.fix.epc = e/t;
- if (session->gpsdata.fix.epc)
+ if (session->gpsdata.fix.epc != UNCERTAINTY_NOT_VALID)
session->gpsdata.set |= CLIMBERR_SET;
}
}
@@ -414,9 +414,10 @@
(void)snprintf(hdop_str,sizeof(hdop_str),"%.2f",session->gpsdata.hdop);
intfixtime = (time_t)session->gpsdata.fix.time;
+ /*@ -usedef -unrecog @*//* splint 3.1.1 doesn't know about gmtime_r */
gmtime_r(&intfixtime, &tm);
if (session->gpsdata.fix.mode > 1) {
- (void)snprintf(bufp, len,
+ (void)snprintf(bufp, (size_t)len,
"$GPGGA,%02d%02d%02d,%09.4f,%c,%010.4f,%c,%d,%02d,%s,%.1f,%c,",
tm.tm_hour,
tm.tm_min,
@@ -429,6 +430,7 @@
session->gpsdata.satellites_used,
hdop_str,
session->gpsdata.fix.altitude, 'M');
+ /*@ +usedef +unrecog @*/
if (session->gpsdata.fix.separation == NO_SEPARATION)
(void)strcat(bufp, ",,");
else
@@ -446,6 +448,7 @@
gpsd_raw_hook(session, bufp, strlen(bufp), 1);
bufp += strlen(bufp);
}
+ /*@ -usedef -unrecog @*//* splint 3.1.1 doesn't know about gmtime_r */
(void)snprintf(bufp, len-strlen(bufp),
"$GPRMC,%02d%02d%02d,%c,%09.4f,%c,%010.4f,%c,%.4f,%.3f,%02d%02d%02d,,",
tm.tm_hour,
@@ -461,6 +464,7 @@
tm.tm_mday,
tm.tm_mon + 1,
tm.tm_year % 100);
+ /*@ +usedef +unrecog @*/
nmea_add_checksum(bufp);
gpsd_raw_hook(session, bufp, strlen(bufp), 1);
}
Modified: trunk/tsip.c
===================================================================
--- trunk/tsip.c 2005-05-29 14:44:04 UTC (rev 2577)
+++ trunk/tsip.c 2005-05-30 09:07:47 UTC (rev 2578)
@@ -114,7 +114,7 @@
static int tsip_analyze(struct gps_device_t *session)
{
- int i, len = 0, mask = 0;
+ int i, len, mask = 0;
unsigned int id;
short s1,s2;
float f1,f2,f3,f4,f5;
@@ -136,20 +136,21 @@
/* remove DLE stuffing and put data part of message in buf */
- buf2[0] = '\0';
+ memset(buf, 0, sizeof(buf));
+ buf2[len = 0] = '\0';
for (i = 2; i < (int)session->outbuflen; i++) {
if (session->outbuffer[i] == 0x10)
if (session->outbuffer[++i] == 0x03)
break;
(void)snprintf(buf2+strlen(buf2),
- sizeof(buf)-strlen(buf),
+ sizeof(buf2)-strlen(buf2),
"%02x", buf[len++] = session->outbuffer[i]);
}
/*@ -charint @*/
(void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag),
- "ID%02x", id = session->outbuffer[1]);
+ "ID%02x", id = (unsigned)session->outbuffer[1]);
gpsd_report(5, "TSIP packet id 0x%02x length %d: %s\n",id,len,buf2);
@@ -165,8 +166,8 @@
s1 = getword(4); /* week */
f2 = getf(6); /* leap seconds */
if (f2 > 10.0) {
- session->gps_week = s1;
- session->context->leap_seconds = roundf(f2);
+ session->gps_week = (unsigned)s1;
+ /*@i@*/session->context->leap_seconds = roundf(f2);
session->context->valid = LEAP_SECOND_VALID;
session->gpsdata.sentence_time = gpstime_to_unix(s1, f1) - f2;
@@ -209,7 +210,7 @@
gpsd_report(4, "Receiver health %02x %02x\n",getbyte(0),getbyte(1));
break;
case 0x47: /* Signal Levels for all Satellites */
- s1 = getbyte(0); /* count */
+ s1 = (short)getbyte(0); /* count */
if (len != (5*s1 + 1))
break;
gpsd_zero_satellites(&session->gpsdata);
@@ -308,14 +309,16 @@
session->gpsdata.hdop = getf(5);
session->gpsdata.vdop = getf(9);
session->gpsdata.tdop = getf(13);
+ /*@ -evalorder @*/
session->gpsdata.gdop = \
sqrt(pow(session->gpsdata.pdop,2)+pow(session->gpsdata.tdop,2)); + /*@ +evalorder @*/
memset(session->gpsdata.used,0,sizeof(session->gpsdata.used));
for (i = 0; i < session->gpsdata.satellites_used; i++)
session->gpsdata.used[i] = getbyte(16 + i);
gpsd_report(4, "Sat info: %d \
%d\n",session->gpsdata.fix.mode,session->gpsdata.satellites_used);
- gpsd_binary_quality_dump(session, buf2, sizeof(buf2));
+ gpsd_binary_quality_dump(session, buf2, (int)sizeof(buf2));
gpsd_report(3, "<= GPS: %s", buf2);
mask |= HDOP_SET | VDOP_SET | PDOP_SET | MODE_SET;
break;
Modified: trunk/xgps.c
===================================================================
--- trunk/xgps.c 2005-05-29 14:44:04 UTC (rev 2577)
+++ trunk/xgps.c 2005-05-30 09:07:47 UTC (rev 2578)
@@ -32,15 +32,17 @@
static Widget label_6, label_7, label_8, label_9, label_10;
static GC gc;
+/*@ -nullassign @*/
static XrmOptionDescRec options[] = {
{"-altunits", "*altunits", XrmoptionSepArg, NULL},
{"-speedunits","*speedunits", XrmoptionSepArg, NULL},
};
String fallback_resources[] = {NULL};
+/*@ +nullassign @*/
struct unit_t {
char *legend;
- float factor;
+ double factor;
};
static struct unit_t speedtable[] = {
{"knots", 1/KNOTS_TO_KPH},
@@ -57,19 +59,21 @@
exit(0); /* closes the GPS along with other fds */
}
+/*@ -mustfreefresh -compdef +ignoresigns @*/
static Pixel get_pixel(Widget w, char *resource_value)
{
Colormap colormap;
- Boolean status;
+ Boolean cstatus;
XColor exact, color;
colormap = DefaultColormapOfScreen(DefaultScreenOfDisplay(XtDisplay(w)));
- status = XAllocNamedColor(XtDisplay(w), colormap, resource_value, &color, \
&exact);
- if (status == 0) {
+ /*@i@*/cstatus = XAllocNamedColor(XtDisplay(w), colormap, resource_value, \
&color, &exact); + if (cstatus == (Boolean)False) {
fprintf(stderr, "Unknown color: %s", resource_value);
color.pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(XtDisplay(w)));
+ return (color.pixel);
};
- return (color.pixel);
+ return 0;
}
static void build_gui(Widget toplevel)
@@ -80,6 +84,7 @@
int i;
XmString string;
+ /*@ -immediatetrans -usedef @*/
/* the root application window */
XtSetArg(args[0], XmNgeometry, "700x570");
XtSetArg(args[1], XmNresizePolicy, XmRESIZE_NONE);
@@ -87,8 +92,10 @@
XtSetArg(args[3], XmNdeleteResponse, XmDO_NOTHING);
XtSetArg(args[4], XmNmwmFunctions,
MWM_FUNC_RESIZE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE);
+ /*@ +immediatetrans +usedef @*/
XtSetValues(toplevel, args, 5);
+ /*@ -onlytrans @*/
/* a form to assist with geometry negotiation */
form = XtVaCreateManagedWidget("form", xmFormWidgetClass, toplevel, NULL);
/* the left half of the screen */
@@ -138,9 +145,11 @@
gc = XCreateGC(XtDisplay(satellite_diagram),
RootWindowOfScreen(XtScreen(satellite_diagram)), GCForeground, &gcv);
register_canvas(satellite_diagram, gc);
- XtAddCallback(satellite_diagram, XmNexposeCallback, (XtPointer)redraw, NULL);
+ /*@i@*/XtAddCallback(satellite_diagram, XmNexposeCallback, (XtPointer)redraw, \
NULL); /* the data display */
+ /*@ -immediatetrans @*/
XtSetArg(args[0], XmNorientation, XmHORIZONTAL);
+ /*@ +immediatetrans @*/
rowColumn_11 = XtCreateManagedWidget("time", xmRowColumnWidgetClass, left, args, \
1);
rowColumn_12 = XtCreateManagedWidget("latitude", xmRowColumnWidgetClass, left, \
args, 1); @@ -165,12 +174,14 @@
label_9 = XtCreateManagedWidget("Climb ", xmLabelWidgetClass, rowColumn_19, \
args, 0);
label_10= XtCreateManagedWidget("Status ", xmLabelWidgetClass, rowColumn_20, \
args, 0);
+ /*@ -immediatetrans @*/
XtSetArg(args[0], XmNcursorPositionVisible, False);
XtSetArg(args[1], XmNeditable, False);
XtSetArg(args[2], XmNmarginHeight, 2);
XtSetArg(args[3], XmNhighlightThickness, 0);
XtSetArg(args[4], XmNshadowThickness, 1);
XtSetArg(args[5], XmNcolumns, 23);
+ /*@ +immediatetrans @*/
text_1 = XtCreateManagedWidget("text_1", xmTextFieldWidgetClass,
rowColumn_11, args, 6);
text_2 = XtCreateManagedWidget("text_2", xmTextFieldWidgetClass,
@@ -194,12 +205,14 @@
quitbutton = XtCreateManagedWidget("Quit",
xmPushButtonWidgetClass, rowColumn_21, args, 0);
- XtAddCallback(quitbutton, XmNactivateCallback, (XtPointer)quit_cb, NULL);
+ /*@i@*/XtAddCallback(quitbutton, XmNactivateCallback, (XtPointer)quit_cb, NULL);
XtRealizeWidget(toplevel);
delw = XmInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False);
- XmAddWMProtocolCallback(toplevel, delw,
+ /*@ -nullpass @*//* splint 3.1.1 lacks annotated prototype... */
+ /*@i@*/XmAddWMProtocolCallback(toplevel, delw,
(XtCallbackProc)quit_cb, (XtPointer)NULL);
+ /*@ +onlytrans +nullpass @*/
/* create empty list items to be replaced on update */
string = XmStringCreateSimple(" ");
@@ -207,6 +220,7 @@
XmListAddItem(satellite_list, string, 0);
XmStringFree(string);
}
+/*@ +mustfreefresh -ignoresigns +immediatetrans @*/
static void handle_time_out(XtPointer client_data UNUSED,
XtIntervalId *ignored UNUSED)
@@ -245,7 +259,7 @@
XmString string[MAXCHANNELS+1];
char s[128], *sp;
- if (message[0])
+ if (message[0] != '\0')
while (isspace(*(sp = message + strlen(message) - 1)))
*sp = '\0';
XmTextFieldSetString(status, message);
@@ -254,7 +268,7 @@
if (gpsdata->satellites) {
for (i = 0; i < MAXCHANNELS; i++) {
if (i < (unsigned int)gpsdata->satellites) {
- (void)snprintf(s, sizeof(s),
+ (void)snprintf(s, sizeof(s),
" %3d %02d %03d %02d %c",
gpsdata->PRN[i],
gpsdata->elevation[i], gpsdata->azimuth[i],
@@ -263,71 +277,71 @@
(void)strcpy(s, " ");
string[i+1] = XmStringCreateSimple(s);
}
- XmListReplaceItemsPos(satellite_list, string, sizeof(string), 1);
- for (i = 0; i < sizeof(string)/sizeof(string[0]); i++)
+ XmListReplaceItemsPos(satellite_list, string, (int)sizeof(string), 1);
+ for (i = 0; i < (unsigned int)(sizeof(string)/sizeof(string[0])); i++)
XmStringFree(string[i]);
}
/* here are the value fields */
if (gpsdata->fix.time != TIME_NOT_VALID)
- unix_to_iso8601(gpsdata->fix.time, s, sizeof(s));
+ (void)unix_to_iso8601(gpsdata->fix.time, s, (int)sizeof(s));
else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_1, s);
if (gpsdata->fix.mode >= MODE_2D)
- sprintf(s, "%lf %c", fabs(gpsdata->fix.latitude), (gpsdata->fix.latitude < 0) ? 'S' \
: 'N'); + (void)snprintf(s, sizeof(s), "%lf %c", fabs(gpsdata->fix.latitude), \
(gpsdata->fix.latitude < 0) ? 'S' : 'N'); else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_2, s);
if (gpsdata->fix.mode >= MODE_2D)
- sprintf(s, "%lf %c", fabs(gpsdata->fix.longitude), (gpsdata->fix.longitude < 0) ? \
'W' : 'E'); + (void)snprintf(s, sizeof(s), "%lf %c", fabs(gpsdata->fix.longitude), \
(gpsdata->fix.longitude < 0) ? 'W' : 'E'); else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_3, s);
if (gpsdata->fix.mode == MODE_3D)
- sprintf(s, "%f %s",gpsdata->fix.altitude*altunits->factor, altunits->legend);
+ (void)snprintf(s, sizeof(s), "%f %s",gpsdata->fix.altitude*altunits->factor, \
altunits->legend); else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_4, s);
if (gpsdata->fix.mode >= MODE_2D && gpsdata->fix.track != TRACK_NOT_VALID)
- sprintf(s, "%f %s", gpsdata->fix.speed*speedunits->factor, speedunits->legend);
+ (void)snprintf(s, sizeof(s), "%f %s", gpsdata->fix.speed*speedunits->factor, \
speedunits->legend); else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_5, s);
if (gpsdata->fix.mode >= MODE_2D && gpsdata->fix.track != TRACK_NOT_VALID)
- sprintf(s, "%f degrees", gpsdata->fix.track);
+ (void)snprintf(s, sizeof(s), "%f degrees", gpsdata->fix.track);
else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_6, s);
if (gpsdata->fix.eph != UNCERTAINTY_NOT_VALID)
- sprintf(s, "%f %s", gpsdata->fix.eph * altunits->factor, altunits->legend);
+ (void)snprintf(s, sizeof(s), "%f %s", gpsdata->fix.eph * altunits->factor, \
altunits->legend); else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_7, s);
if (gpsdata->fix.epv != UNCERTAINTY_NOT_VALID)
- sprintf(s, "%f %s", gpsdata->fix.epv * altunits->factor, altunits->legend);
+ (void)snprintf(s, sizeof(s), "%f %s", gpsdata->fix.epv * altunits->factor, \
altunits->legend); else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_8, s);
if (gpsdata->fix.mode == MODE_3D)
- sprintf(s, "%f %s/sec", gpsdata->fix.climb * altunits->factor, altunits->legend);
+ (void)snprintf(s, sizeof(s), "%f %s/sec", gpsdata->fix.climb * altunits->factor, \
altunits->legend); else
(void)strcpy(s, "n/a");
XmTextFieldSetString(text_9, s);
- if (!gpsdata->online) {
+ if (gpsdata->online == 0) {
newstate = 0;
- sprintf(s, "OFFLINE");
+ (void)snprintf(s, sizeof(s), "OFFLINE");
} else {
newstate = gpsdata->fix.mode;
switch (gpsdata->fix.mode) {
case MODE_2D:
- sprintf(s, "2D %sFIX",(gpsdata->status==STATUS_DGPS_FIX)?"DIFF ":"");
+ (void)snprintf(s, sizeof(s), "2D \
%sFIX",(gpsdata->status==STATUS_DGPS_FIX)?"DIFF ":""); break;
case MODE_3D:
- sprintf(s, "3D %sFIX",(gpsdata->status==STATUS_DGPS_FIX)?"DIFF ":"");
+ (void)snprintf(s, sizeof(s), "3D \
%sFIX",(gpsdata->status==STATUS_DGPS_FIX)?"DIFF ":""); break;
default:
- sprintf(s, "NO FIX");
+ (void)snprintf(s, sizeof(s), "NO FIX");
break;
}
}
@@ -335,7 +349,8 @@
timer = time(NULL);
state = newstate;
}
- sprintf(s + strlen(s), " (%d secs)", (int) (time(NULL) - timer));
+ (void)snprintf(s+strlen(s), sizeof(s)-strlen(s),
+ " (%d secs)", (int) (time(NULL) - timer));
XmTextFieldSetString(text_10, s);
draw_graphics(gpsdata);
@@ -348,29 +363,34 @@
XtResource xtr;
char *value = NULL;
+ /*@ -observertrans -statictrans -immediatetrans -compdestroy @*/
xtr.resource_name = name;
xtr.resource_class = "AnyClass";
xtr.resource_type = XmRString;
- xtr.resource_size = sizeof(String);
+ xtr.resource_size = (Cardinal)sizeof(String);
xtr.resource_offset = 0;
xtr.default_type = XmRImmediate;
xtr.default_addr = default_value;
XtGetApplicationResources(w, &value, &xtr, 1, NULL, 0);
if (value) return value;
- return default_value;
+ /*@ +observertrans +statictrans +immediatetrans +compdestroy @*/
+ /*@i@*/return default_value;
}
+/*@ -mustfreefresh @*/
int main(int argc, char *argv[])
{
int option;
- char *arg, *colon1, *colon2, *device = NULL, *server = NULL, *port = \
DEFAULT_GPSD_PORT; + char *arg = NULL, *colon1, *colon2, *device = NULL, *server = \
NULL, *port = DEFAULT_GPSD_PORT; char *su, *au;
char *err_str = NULL;
+ /*@ -onlytrans */
toplevel = XtVaAppInitialize(&app, "xgps",
options, XtNumber(options),
&argc,argv, fallback_resources,NULL);
+ /*@ +onlytrans */
su = get_resource(toplevel, "speedunits", "mph");
for (speedunits = speedtable;
speedunits < speedtable + sizeof(speedtable)/sizeof(speedtable[0]);
@@ -401,9 +421,10 @@
exit(1);
}
}
+ /*@ -branchstate @*/
if (optind < argc) {
arg = strdup(argv[optind]);
- colon1 = strchr(arg, ':');
+ /*@i@*/colon1 = strchr(arg, ':');
server = arg;
if (colon1 != NULL) {
if (colon1 == arg)
@@ -420,7 +441,9 @@
device = colon2 + 1;
}
}
+ colon1 = colon2 = NULL;
}
+ /*@ +branchstate @*/
gpsdata = gps_open(server, port);
if (!gpsdata) {
@@ -448,9 +471,12 @@
if (device) {
char *channelcmd = (char *)malloc(strlen(device)+3);
- (void)strcpy(channelcmd, "F=");
- (void)strcpy(channelcmd+2, device);
- (void)gps_query(gpsdata, channelcmd);
+ if (channelcmd) {
+ /*@i1@*/(void)strcpy(channelcmd, "F=");
+ (void)strcpy(channelcmd+2, device);
+ (void)gps_query(gpsdata, channelcmd);
+ (void)free(channelcmd);
+ }
}
(void)gps_query(gpsdata, "w+x\n");
@@ -460,5 +486,8 @@
(void)XtAppMainLoop(app);
(void)gps_close(gpsdata);
+ if (arg != NULL)
+ (void)free(arg);
return 0;
}
+/*@ +mustfreefresh @*/
Modified: trunk/xgpsspeed.c
===================================================================
--- trunk/xgpsspeed.c 2005-05-29 14:44:04 UTC (rev 2577)
+++ trunk/xgpsspeed.c 2005-05-30 09:07:47 UTC (rev 2578)
@@ -47,11 +47,12 @@
}
}
-static char *get_resource(char *name, char *default_value)
+static char *get_resource(Widget w, char *name, char *default_value)
{
XtResource xtr;
char *value = NULL;
+ /*@ -observertrans -statictrans -immediatetrans -compdestroy -nullpass @*/
xtr.resource_name = name;
xtr.resource_class = "AnyClass";
xtr.resource_type = XmRString;
@@ -59,26 +60,30 @@
xtr.resource_offset = 0;
xtr.default_type = XmRImmediate;
xtr.default_addr = default_value;
- (void)XtGetApplicationResources(toplevel, &value, &xtr, 1, NULL, 0);
+ XtGetApplicationResources(w, &value, &xtr, 1, NULL, 0);
if (value) return value;
- return default_value;
+ /*@ +observertrans +statictrans +immediatetrans +compdestroy +nullpass @*/
+ /*@i@*/return default_value;
}
+/*@ -mustfreefresh @*/
int main(int argc, char **argv)
{
Arg args[10];
XtAppContext app;
int option;
- char *arg, *colon1, *colon2, *device = NULL, *server = NULL, *port = \
DEFAULT_GPSD_PORT; + char *arg = NULL, *colon1, *colon2, *device = NULL, *server = \
NULL, *port = DEFAULT_GPSD_PORT; char *speedunits;
Widget base;
+ /*@ -compdef -nullpass @*/
toplevel = XtVaAppInitialize(&app, "xgpsspeed",
options, XtNumber(options),
&argc, argv, fallback_resources, NULL);
+ /*@ +compdef +nullpass @*/
speedfactor = MPS_TO_MPH; /* Software maintained in US */
- speedunits = get_resource("speedunits", "mph");
+ speedunits = get_resource(toplevel, "speedunits", "mph");
if (strcmp(speedunits, "kph")==0)
speedfactor = MPS_TO_KPH;
else if (strcmp(speedunits, "knots")==0)
@@ -87,13 +92,14 @@
while ((option = getopt(argc, argv, "hv")) != -1) {
switch (option) {
case 'v':
- printf("xgpsspeed %s\n", VERSION);
+ (void)printf("xgpsspeed %s\n", VERSION);
exit(0);
case 'h': default:
- fputs("usage: gps [-h] [-v] [-rv] [-nc] [-needlecolor] [-speedunits \
{mph,kph,knots}] [server[:port]]\n", stderr); + (void)fputs("usage: gps [-h] [-v] \
[-rv] [-nc] [-needlecolor] [-speedunits {mph,kph,knots}] [server[:port]]\n", stderr); \
exit(1); }
}
+ /*@ -branchstate @*/
if (optind < argc) {
arg = strdup(argv[optind]);
colon1 = strchr(arg, ':');
@@ -113,7 +119,9 @@
device = colon2 + 1;
}
}
+ colon1 = colon2 = NULL;
}
+ /*@ +branchstate @*/
/**** Shell Widget ****/
(void)XtSetArg(args[0], XtNiconPixmap,
@@ -141,11 +149,11 @@
(void)XtRealizeWidget(toplevel);
if (!(gpsdata = gps_open(server, DEFAULT_GPSD_PORT))) {
- fputs("xgpsspeed: no gpsd running or network error\n", stderr);
+ (void)fputs("xgpsspeed: no gpsd running or network error\n", stderr);
exit(2);
}
- XtAppAddInput(app, gpsdata->gps_fd, (XtPointer) XtInputReadMask,
+ (void)XtAppAddInput(app, gpsdata->gps_fd, (XtPointer) XtInputReadMask,
handle_input, NULL);
gps_set_raw_hook(gpsdata, update_display);
@@ -153,15 +161,21 @@
if (device) {
char *channelcmd = (char *)malloc(strlen(device)+3);
- (void)strcpy(channelcmd, "F=");
- (void)strcpy(channelcmd+2, device);
- (void)gps_query(gpsdata, channelcmd);
+ if (channelcmd) {
+ /*@i1@*/(void)strcpy(channelcmd, "F=");
+ (void)strcpy(channelcmd+2, device);
+ (void)gps_query(gpsdata, channelcmd);
+ (void)free(channelcmd);
+ }
}
(void)gps_query(gpsdata, "w+x\n");
(void)XtAppMainLoop(app);
- gps_close(gpsdata);
+ (void)gps_close(gpsdata);
+ if (arg != NULL)
+ (void)free(arg);
return 0;
}
+/*@ +mustfreefresh @*/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic