Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Commit

Permalink
Fix compilation warnings
Browse files Browse the repository at this point in the history
Fix comments. Remove unused variables. Fix variable types for struct.
  • Loading branch information
James Barnett committed Oct 25, 2016
1 parent c1d0b3a commit ecd7d7b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 58 deletions.
4 changes: 0 additions & 4 deletions include/xdrfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
*
* $Id: xdrfile.h,v 1.1 2010/10/08 11:53:37 spoel Exp spoel $
*
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
* Copyright (c) 2009-2014, Erik Lindahl & David van der Spoel
* All rights reserved.
*
Expand Down
10 changes: 2 additions & 8 deletions include/xdrfile_trr.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
Expand All @@ -12,8 +8,7 @@
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
this
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
Expand All @@ -22,8 +17,7 @@
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Expand Down
10 changes: 2 additions & 8 deletions include/xdrfile_xtc.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
Expand All @@ -12,8 +8,7 @@
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
this
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
Expand All @@ -22,8 +17,7 @@
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Expand Down
3 changes: 1 addition & 2 deletions src/trr_seek.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ int read_trr_n_frames(char *fn, int *n_frames, int *est_nframes,
int64_t **offsets) {
XDRFILE *xd;
t_trnheader sh;
float time, lambda;
int result, framebytes, totalframebytes;
int result, framebytes;
int64_t filesize, frame_offset;

if ((xd = xdrfile_open(fn, "r")) == NULL)
Expand Down
37 changes: 6 additions & 31 deletions src/xdrfile.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
Expand Down Expand Up @@ -129,8 +125,8 @@ struct XDR
int (*x_getbytes) (XDR *__xdrs, char *__addr, unsigned int __len);
int (*x_putbytes) (XDR *__xdrs, char *__addr, unsigned int __len);
/* two next routines are not 64-bit IO safe - don't use! */
unsigned int (*x_getpostn) (XDR *__xdrs);
int (*x_setpostn) (XDR *__xdrs, unsigned int __pos);
off_t (*x_getpostn) (XDR *__xdrs);
int (*x_setpostn) (XDR *__xdrs, off_t __pos, int whence);
void (*x_destroy) (XDR *__xdrs);
}
*x_ops;
Expand Down Expand Up @@ -785,10 +781,10 @@ xdrfile_decompress_coord_float(float *ptr,
XDRFILE* xfp)
{
int minint[3], maxint[3], *lip;
int smallidx, minidx, maxidx;
int smallidx;
unsigned sizeint[3], sizesmall[3], bitsizeint[3], size3;
int k, *buf1, *buf2, lsize, flag;
int smallnum, smaller, larger, i, is_smaller, run;
int smallnum, smaller, i, is_smaller, run;
float *lfp, inv_precision;
int tmp, *thiscoord, prevcoord[3];
unsigned int bitsize;
Expand Down Expand Up @@ -862,14 +858,11 @@ xdrfile_decompress_coord_float(float *ptr,
if (xdrfile_read_int(&smallidx,1,xfp) == 0)
return 0; /* not sure what has happened here or why we return... */
tmp=smallidx+8;
maxidx = (LASTIDX<tmp) ? LASTIDX : tmp;
minidx = maxidx - 8; /* often this equal smallidx */
tmp = smallidx-1;
tmp = (FIRSTIDX>tmp) ? FIRSTIDX : tmp;
smaller = magicints[tmp] / 2;
smallnum = magicints[smallidx] / 2;
sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ;
larger = magicints[maxidx];

/* buf2[0] holds the length in bytes */

Expand Down Expand Up @@ -995,7 +988,6 @@ xdrfile_compress_coord_float(float *ptr,
float *lfp, lf;
int tmp, tmpsum, *thiscoord, prevcoord[3];
unsigned int tmpcoord[30];
int errval=1;
unsigned int bitsize;

if(xfp==NULL)
Expand Down Expand Up @@ -1056,7 +1048,6 @@ xdrfile_compress_coord_float(float *ptr,
{
/* scaling would cause overflow */
fprintf(stderr,"Internal overflow compressing coordinates.\n");
errval=0;
}
lint1 = lf;
if (lint1 < minint[0]) minint[0] = lint1;
Expand All @@ -1071,7 +1062,6 @@ xdrfile_compress_coord_float(float *ptr,
{
/* scaling would cause overflow */
fprintf(stderr,"Internal overflow compressing coordinates.\n");
errval=0;
}
lint2 = lf;
if (lint2 < minint[1]) minint[1] = lint2;
Expand All @@ -1082,10 +1072,6 @@ xdrfile_compress_coord_float(float *ptr,
lf = *lfp * precision + 0.5;
else
lf = *lfp * precision - 0.5;
if (fabs(lf) > INT_MAX-2)
{
errval=0;
}
lint3 = lf;
if (lint3 < minint[2]) minint[2] = lint3;
if (lint3 > maxint[2]) maxint[2] = lint3;
Expand All @@ -1108,7 +1094,6 @@ xdrfile_compress_coord_float(float *ptr,
* would cause overflow
*/
fprintf(stderr,"Internal overflow compressing coordinates.\n");
errval=0;
}
sizeint[0] = maxint[0] - minint[0]+1;
sizeint[1] = maxint[1] - minint[1]+1;
Expand Down Expand Up @@ -1281,10 +1266,10 @@ xdrfile_decompress_coord_double(double *ptr,
XDRFILE* xfp)
{
int minint[3], maxint[3], *lip;
int smallidx, minidx, maxidx;
int smallidx;
unsigned sizeint[3], sizesmall[3], bitsizeint[3], size3;
int k, *buf1, *buf2, lsize, flag;
int smallnum, smaller, larger, i, is_smaller, run;
int smallnum, smaller, i, is_smaller, run;
double *lfp, inv_precision;
float float_prec, tmpdata[30];
int tmp, *thiscoord, prevcoord[3];
Expand Down Expand Up @@ -1362,14 +1347,11 @@ xdrfile_decompress_coord_double(double *ptr,
if (xdrfile_read_int(&smallidx,1,xfp) == 0)
return 0;
tmp=smallidx+8;
maxidx = (LASTIDX<tmp) ? LASTIDX : tmp;
minidx = maxidx - 8; /* often this equal smallidx */
tmp = smallidx-1;
tmp = (FIRSTIDX>tmp) ? FIRSTIDX : tmp;
smaller = magicints[tmp] / 2;
smallnum = magicints[smallidx] / 2;
sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ;
larger = magicints[maxidx];

/* buf2[0] holds the length in bytes */

Expand Down Expand Up @@ -1488,7 +1470,6 @@ xdrfile_compress_coord_double(double *ptr,
float float_prec, lf,tmpdata[30];
int tmp, tmpsum, *thiscoord, prevcoord[3];
unsigned int tmpcoord[30];
int errval=1;
unsigned int bitsize;

bitsizeint[0] = 0;
Expand Down Expand Up @@ -1545,7 +1526,6 @@ xdrfile_compress_coord_double(double *ptr,
if (fabs(lf) > INT_MAX-2) {
/* scaling would cause overflow */
fprintf(stderr,"Internal overflow compressing coordinates.\n");
errval=0;
}
lint1 = lf;
if (lint1 < minint[0]) minint[0] = lint1;
Expand All @@ -1559,7 +1539,6 @@ xdrfile_compress_coord_double(double *ptr,
if (fabs(lf) > INT_MAX-2) {
/* scaling would cause overflow */
fprintf(stderr,"Internal overflow compressing coordinates.\n");
errval=0;
}
lint2 = lf;
if (lint2 < minint[1]) minint[1] = lint2;
Expand All @@ -1570,9 +1549,6 @@ xdrfile_compress_coord_double(double *ptr,
lf = (float)*lfp * float_prec + 0.5;
else
lf = (float)*lfp * float_prec - 0.5;
if (fabs(lf) > INT_MAX-2) {
errval=0;
}
lint3 = lf;
if (lint3 < minint[2]) minint[2] = lint3;
if (lint3 > maxint[2]) maxint[2] = lint3;
Expand All @@ -1595,7 +1571,6 @@ xdrfile_compress_coord_double(double *ptr,
* would cause overflow
*/
fprintf(stderr,"Internal overflow compressing coordinates.\n");
errval=0;
}
sizeint[0] = maxint[0] - minint[0]+1;
sizeint[1] = maxint[1] - minint[1]+1;
Expand Down
6 changes: 1 addition & 5 deletions src/xdrfile_trr.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* $Id$
*
Expand Down Expand Up @@ -410,7 +406,7 @@ int read_trr_natoms(char *fn, int *natoms) {

int write_trr(XDRFILE *xd, int natoms, int step, float t, float lambda,
matrix box, rvec *x, rvec *v, rvec *f) {
int *plcholder;
int *plcholder = NULL;
return do_trn(xd, 0, &step, &t, &lambda, box, &natoms, x, v, f, plcholder);
}

Expand Down

0 comments on commit ecd7d7b

Please sign in to comment.