Add FITSint() and FITSuint(),

which cast long long to int while panicking on overflow
This commit is contained in:
nhkeni
2022-03-17 18:10:38 -04:00
parent e2d5013e01
commit 7dba4f1236
9 changed files with 62 additions and 10 deletions
+11
View File
@@ -17,6 +17,7 @@
static void xexit(int) NORETURN;
char *eos(char *); /* also used by dlb.c */
FILE *fopen_datafile(const char *, const char *);
unsigned FITSuint_(unsigned long long, const char *, int);
#ifdef DLB
#ifdef DLBLIB
@@ -543,4 +544,14 @@ xexit(int retcd)
/*NOTREACHED*/
}
/* In hacklib.c, but we don't have that and it calls panic() */
unsigned
FITSuint_(unsigned long long i, const char *file, int line){
unsigned ret = (unsigned)i;
if (ret != i) {
printf("Overflow at %s:%d\n", file, line);
xexit(EXIT_FAILURE);
}
return (unsigned)i;
}
/*dlb_main.c*/