Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit df07459

Browse files
author
Reini Urban
committed
coverity: fix write_write_typo: In asmb = asmb =
Evaluation order violation asmb is written twice with the same value. Declare all malloc results as volatile.
1 parent 962d954 commit df07459

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

‎core/asm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
PNAsm *potion_asm_new(Potion *P) {
1414
int siz = ASM_UNIT - sizeof(PNAsm);
15-
PNAsm * volatile asmb = PN_FLEX_NEW(asmb, PN_TBYTES, PNAsm, siz);
15+
PNAsm * volatile asmb;
16+
PN_FLEX_NEW(asmb, PN_TBYTES, PNAsm, siz);
1617
return asmb;
1718
}
1819

‎core/internal.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ struct Potion_State;
99

1010
typedef unsigned char u8;
1111

12-
#define PN_ALLOC(V,T) (T *)potion_gc_alloc(P, V, sizeof(T))
13-
#define PN_ALLOC_N(V,T,C) (T *)potion_gc_alloc(P, V, sizeof(T)+C)
14-
#define PN_CALLOC_N(V,T,C) (T *)potion_gc_calloc(P, V, sizeof(T)+C)
15-
#define PN_REALLOC(X,V,T,N) (X)=(T *)potion_gc_realloc(P, V, (struct PNObject *)(X), sizeof(T) + N)
12+
#define PN_ALLOC(V,T) (T * volatile)potion_gc_alloc(P, V, sizeof(T))
13+
#define PN_ALLOC_N(V,T,C) (T * volatile)potion_gc_alloc(P, V, sizeof(T)+C)
14+
#define PN_CALLOC_N(V,T,C) (T * volatile)potion_gc_calloc(P, V, sizeof(T)+C)
15+
#define PN_REALLOC(X,V,T,N) (X)=(T * volatile)potion_gc_realloc(P, V, (struct PNObject *)(X), sizeof(T) + N)
1616
#define PN_DALLOC_N(T,N) potion_data_alloc(P, sizeof(T)*N)
1717
#define PN_STRDUP(S) PN_STR(S)
1818

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /