Skip to content

Commit

Permalink
Closer to C89 compliance, fixed store_flags bug
Browse files Browse the repository at this point in the history
store_flags would not be set when no conversion was needed, storage_free
would get wrong and uninitialized values
  • Loading branch information
mnunberg committed Feb 1, 2012
1 parent 90c6b30 commit e7d3f39
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 17 deletions.
15 changes: 8 additions & 7 deletions Client_multi.xs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ _cmd2storop(int cmd)
static SV* static SV*
PLCB_multi_get_common(SV *self, AV *args, int cmd) PLCB_multi_get_common(SV *self, AV *args, int cmd)
{ {
_dMULTI_VARS; _dMULTI_VARS


void **keys; void **keys;
size_t *sizes; size_t *sizes;
time_t *exps; time_t *exps;
SV **tmpsv; SV **tmpsv;
PLCB_sync_t *syncp;


void *keys_stacked[MULTI_STACK_ELEM]; void *keys_stacked[MULTI_STACK_ELEM];
size_t sizes_stacked[MULTI_STACK_ELEM]; size_t sizes_stacked[MULTI_STACK_ELEM];
Expand All @@ -121,7 +122,7 @@ PLCB_multi_get_common(SV *self, AV *args, int cmd)
mk_instance_vars(self, instance, object); mk_instance_vars(self, instance, object);
_MULTI_INIT_COMMON(object, ret, nreq, args, now); _MULTI_INIT_COMMON(object, ret, nreq, args, now);


PLCB_sync_t *syncp = &object->sync; syncp = &object->sync;
syncp->parent = object; syncp->parent = object;
syncp->ret = (AV*)ret; syncp->ret = (AV*)ret;


Expand Down Expand Up @@ -196,7 +197,7 @@ PLCB_multi_get_common(SV *self, AV *args, int cmd)
static SV* static SV*
PLCB_multi_set_common(SV *self, AV *args, int cmd) PLCB_multi_set_common(SV *self, AV *args, int cmd)
{ {
_dMULTI_VARS; _dMULTI_VARS
PLCB_sync_t *syncs = NULL; PLCB_sync_t *syncs = NULL;
PLCB_sync_t syncs_stacked[MULTI_STACK_ELEM]; PLCB_sync_t syncs_stacked[MULTI_STACK_ELEM];
libcouchbase_storage_t storop; libcouchbase_storage_t storop;
Expand All @@ -221,8 +222,8 @@ PLCB_multi_set_common(SV *self, AV *args, int cmd)
SV **tmpsv; SV **tmpsv;
char *value; char *value;
STRLEN nvalue; STRLEN nvalue;
SV *value_sv; SV *value_sv = NULL;
uint32_t store_flags; uint32_t store_flags = 0;
uint64_t cas = 0; uint64_t cas = 0;
time_t exp = 0; time_t exp = 0;


Expand Down Expand Up @@ -277,7 +278,7 @@ PLCB_multi_set_common(SV *self, AV *args, int cmd)
static SV* static SV*
PLCB_multi_arithmetic_common(SV *self, AV *args, int cmd) PLCB_multi_arithmetic_common(SV *self, AV *args, int cmd)
{ {
_dMULTI_VARS; _dMULTI_VARS


PLCB_sync_t *syncs; PLCB_sync_t *syncs;
PLCB_sync_t syncs_stacked[MULTI_STACK_ELEM]; PLCB_sync_t syncs_stacked[MULTI_STACK_ELEM];
Expand Down Expand Up @@ -365,7 +366,7 @@ PLCB_multi_arithmetic_common(SV *self, AV *args, int cmd)
static SV* static SV*
PLCB_multi_remove(SV *self, AV *args) PLCB_multi_remove(SV *self, AV *args)
{ {
_dMULTI_VARS; _dMULTI_VARS
PLCB_sync_t *syncs = NULL; PLCB_sync_t *syncs = NULL;
PLCB_sync_t syncs_stacked[MULTI_STACK_ELEM]; PLCB_sync_t syncs_stacked[MULTI_STACK_ELEM];


Expand Down
3 changes: 2 additions & 1 deletion Makefile.PL
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ WriteMakefile(
'POE' => 1.312, 'POE' => 1.312,
}, },
NEEDS_LINKING => 1, NEEDS_LINKING => 1,
OPTIMIZE => '-O0 -ggdb3', OPTIMIZE => '-O0 -ggdb3 -Wdeclaration-after-statement -Werror -std=gnu89',
#CCFLAGS => '-Wdeclaration-after-statement',
LIBS => ["$library_path -lcouchbase -lcouchbase_libevent"], LIBS => ["$library_path -lcouchbase -lcouchbase_libevent"],
INC => $include_path, INC => $include_path,
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
Expand Down
2 changes: 1 addition & 1 deletion async.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -468,4 +468,4 @@ PLCBA_DESTROY(SV *self)
/*cleanup our base object. This will also cause the events to be destroyed*/ /*cleanup our base object. This will also cause the events to be destroyed*/
plcb_cleanup(&async->base); plcb_cleanup(&async->base);
Safefree(async); Safefree(async);
} }
2 changes: 1 addition & 1 deletion async_events.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -352,4 +352,4 @@ plcba_make_io_opts(PLCBA_t *async)
cbcio->destructor = destructor; cbcio->destructor = destructor;


return cbcio; return cbcio;
} }
2 changes: 1 addition & 1 deletion callbacks.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ void plcb_callback_error(
libcouchbase_error_t err, libcouchbase_error_t err,
const char *errinfo) const char *errinfo)
{ {
warn("Got error callback");
PLCB_t *object; PLCB_t *object;
SV *elem_list[2]; SV *elem_list[2];
warn("Got error callback");


if(err == LIBCOUCHBASE_SUCCESS) { if(err == LIBCOUCHBASE_SUCCESS) {
return; return;
Expand Down
3 changes: 2 additions & 1 deletion convert.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void plcb_convert_storage(
uint32_t *flags) uint32_t *flags)
{ {
SV *sv; SV *sv;
*flags = 0;


if(object->my_flags & PLCBf_DO_CONVERSION == 0 && SvROK(*data_sv) == 0) { if(object->my_flags & PLCBf_DO_CONVERSION == 0 && SvROK(*data_sv) == 0) {
return; return;
Expand Down Expand Up @@ -220,4 +221,4 @@ int plcb_convert_settings(PLCB_t *object, int flag, int new_value)
} }


return ret; return ret;
} }
2 changes: 1 addition & 1 deletion ctor.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ void plcb_ctor_init_common(PLCB_t *object, libcouchbase_t instance,
object->my_flags |= PLCBf_NO_CONNECT; object->my_flags |= PLCBf_NO_CONNECT;
} }
/*maybe more stuff here?*/ /*maybe more stuff here?*/
} }
2 changes: 1 addition & 1 deletion lib/Couchbase/Test/ClientSync.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ sub T05_conversion :Test(no_plan) {
} }


sub _multi_check_ret { sub _multi_check_ret {
my ($rv,$keys) = @_; my ($rv,$keys) = @_;
my $nkeys = scalar @$keys; my $nkeys = scalar @$keys;
my $defined = scalar grep defined $_, values %$rv; my $defined = scalar grep defined $_, values %$rv;
my $n_ok = scalar grep $_->is_ok, values %$rv; my $n_ok = scalar grep $_->is_ok, values %$rv;
Expand Down
2 changes: 1 addition & 1 deletion perl-couchbase-async.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -273,4 +273,4 @@ void PLCBA_HaveEvent(const char*, short, SV*);
void PLCBA_request(SV *, int, int, SV*, SV*, int, AV*); void PLCBA_request(SV *, int, int, SV*, SV*, int, AV*);




#endif /* PERL_COUCHBASE_ASYNC_H_ */ #endif /* PERL_COUCHBASE_ASYNC_H_ */
2 changes: 1 addition & 1 deletion plcb-return.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ plcb_ret_set_numval(PLCB_t *obj, AV *ret, uint64_t value, uint64_t cas)
#define plcb_ret_blessed_rv(obj, ret) \ #define plcb_ret_blessed_rv(obj, ret) \
sv_bless(newRV_noinc( (SV*)(ret)), (obj)->ret_stash) sv_bless(newRV_noinc( (SV*)(ret)), (obj)->ret_stash)


#endif /*PLCB_RETURN_H_*/ #endif /*PLCB_RETURN_H_*/
2 changes: 1 addition & 1 deletion plcb-util.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ static inline uint64_t plcb_sv_to_u64(SV *in)






#endif /* PLCB_UTIL_H_ */ #endif /* PLCB_UTIL_H_ */

0 comments on commit e7d3f39

Please sign in to comment.