Skip to content

Commit

Permalink
coverity: Pointer to local outside scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Reini Urban committed Nov 8, 2015
1 parent 8828878 commit af2e8b8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/file.c
Expand Up @@ -118,15 +118,15 @@ PN potion_file_read(Potion *P, PN cl, pn_file self, PN n) {
PN potion_file_write(Potion *P, PN cl, pn_file self, PN obj) {
long len = 0;
char *ptr = NULL;
double tmp;
union { double d; long l; char c; } tmp;
//TODO: maybe extract ptr+len to seperate function
if (!PN_IS_PTR(obj)) {
if (!obj) return PN_NIL; //silent
else if (PN_IS_INT(obj)) {
long tmp = PN_NUM(obj); len = sizeof(tmp); ptr = (char *)&tmp;
tmp.l = PN_NUM(obj); len = sizeof(tmp); ptr = (char *)&tmp.l;
}
else if (PN_IS_BOOL(obj)) {
char tmp = (obj == PN_TRUE) ? 1 : 0; len = 1; ptr = (char *)&tmp;
tmp.c = (obj == PN_TRUE) ? 1 : 0; len = 1; ptr = (char *)&tmp.c;
}
else {
assert(0 && "Invalid primitive type");
Expand All @@ -136,7 +136,7 @@ PN potion_file_write(Potion *P, PN cl, pn_file self, PN obj) {
case PN_TSTRING: len = PN_STR_LEN(obj); ptr = PN_STR_PTR(obj); break;
case PN_TBYTES: len = potion_send(obj, PN_STR("length")); ptr = PN_STR_PTR(obj); break;
case PN_TNUMBER: {
tmp = PN_DBL(obj); len = sizeof(tmp); ptr = (char *)&tmp;
tmp.d = PN_DBL(obj); len = sizeof(tmp); ptr = (char *)&tmp.d;
break;
}
default: return potion_type_error(P, obj);
Expand Down

0 comments on commit af2e8b8

Please sign in to comment.