Thread: Re: bug fix: read write header

Started: 2006-02-16 18:17:47
Last activity: 2006-02-16 18:17:47
Topics: SAC Developers
Brian Savage
2006-02-16 18:17:47
Chad,

You are correct. Thanks.

Cheers,
Brian

Chad wrote:

Hi Brian,

I was throwing together a quick SAC to Mini-SEED converter and looked at
your recent patch for detecting byte order from the SAC header (thanks).
I think I see an error (see below), feel free to tell me I'm wrong.

cheers,
Chad

Index: src/dff/wrsac.c
===================================================================
RCS file: /export/home/cvs/repository/SAC/src/dff/wrsac.c,v
...
+ hdrVer = (long *) (header + versionLocation * 4);
+ if(hdrVer < 1 || *hdrVer > cmhdr.nvhdrc) {

Testing (hdrVer < 1) here but probably want (*hdrVer < 1), heck this
test is probably always true, the pointer should always be more than 1 :)

+ byteswap( (void *) hdrVer, 4);
+ if(*hdrVer < 1 || *hdrVer > cmhdr.nvhdrc) {

The first test should be like this one, no?

+ *nerr = 1317;
+ setmsg("ERROR", *nerr);
+ /* apcmsg2(&kmdfm.kdflrq[ic1 - 1], ic2-ic1+1); */
+ aplmsg("not is sac format, nor byteswapped sac format.", 62);
+ free(header);
+ goto L_8888;
+ } else {
+ free(header);
+ lswap = TRUE;
+ }
+ }



14:03:03 v.01697673