[master] 3d0438f Fix a potential use of an unintialized stack variable.
Poul-Henning Kamp
phk at varnish-cache.org
Sat Jun 29 15:43:59 CEST 2013
commit 3d0438f7a091b3677a5f614bab5c5f53dab48626
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat Jun 29 13:43:21 2013 +0000
Fix a potential use of an unintialized stack variable.
Constification
Constification.
diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h
index ad5ee26..8fa7660 100644
--- a/include/vapi/vsc.h
+++ b/include/vapi/vsc.h
@@ -59,8 +59,8 @@ int VSC_Arg(struct VSM_data *vd, int arg, const char *opt);
* 1 Handled.
*/
-struct VSC_C_mgt *VSC_Mgt(struct VSM_data *vd, struct VSM_fantom *fantom);
-struct VSC_C_main *VSC_Main(struct VSM_data *vd, struct VSM_fantom *fantom);
+struct VSC_C_mgt *VSC_Mgt(const struct VSM_data *vd, struct VSM_fantom *fantom);
+struct VSC_C_main *VSC_Main(const struct VSM_data *vd, struct VSM_fantom *fantom);
/*
* Looks up and returns the management stats and the child main
* stats structure. If fantom is non-NULL, it can later be used
@@ -80,7 +80,7 @@ struct VSC_C_main *VSC_Main(struct VSM_data *vd, struct VSM_fantom *fantom);
* non-NULL: Success
*/
-void *VSC_Get(struct VSM_data *vd, struct VSM_fantom *fantom, const char *type,
+void *VSC_Get(const struct VSM_data *vd, struct VSM_fantom *fantom, const char *type,
const char *ident);
/*
* Looks up the given VSC type and identifier. If fantom is
diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h
index 138e920..daf5366 100644
--- a/include/vapi/vsl.h
+++ b/include/vapi/vsl.h
@@ -224,7 +224,7 @@ int VSL_Match(struct VSL_data *vsl, const struct VSL_cursor *c);
* 0: No match
*/
-int VSL_Print(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo);
+int VSL_Print(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo);
/*
* Print the log record pointed to by cursor to stream.
*
@@ -242,7 +242,7 @@ int VSL_Print(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo);
* -5: I/O write error - see errno
*/
-int VSL_PrintTerse(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo);
+int VSL_PrintTerse(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo);
/*
* Print the log record pointed to by cursor to stream.
*
@@ -311,7 +311,7 @@ FILE *VSL_WriteOpen(struct VSL_data *vsl, const char *name, int append,
*/
-int VSL_Write(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo);
+int VSL_Write(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo);
/*
* Write the currect record pointed to be c to the FILE* fo
*
diff --git a/include/vapi/vsm.h b/include/vapi/vsm.h
index caddcb9..d4277a4 100644
--- a/include/vapi/vsm.h
+++ b/include/vapi/vsm.h
@@ -54,6 +54,8 @@ struct VSM_fantom {
char ident[VSM_IDENT_LEN];
};
+#define VSM_FANTOM_NULL { 0, 0, 0, 0, {0}, {0}, {0} }
+
/*---------------------------------------------------------------------
* VSM level access functions
*/
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index ec4b385..c573fb8 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -39,7 +39,6 @@
#include "miniobj.h"
#include "vas.h"
-#include "vdef.h"
#include "vapi/vsc.h"
#include "vapi/vsm.h"
@@ -262,7 +261,7 @@ VSC_Arg(struct VSM_data *vd, int arg, const char *opt)
/*--------------------------------------------------------------------*/
struct VSC_C_mgt *
-VSC_Mgt(struct VSM_data *vd, struct VSM_fantom *fantom)
+VSC_Mgt(const struct VSM_data *vd, struct VSM_fantom *fantom)
{
return (VSC_Get(vd, fantom, VSC_type_mgt, ""));
@@ -271,7 +270,7 @@ VSC_Mgt(struct VSM_data *vd, struct VSM_fantom *fantom)
/*--------------------------------------------------------------------*/
struct VSC_C_main *
-VSC_Main(struct VSM_data *vd, struct VSM_fantom *fantom)
+VSC_Main(const struct VSM_data *vd, struct VSM_fantom *fantom)
{
return (VSC_Get(vd, fantom, VSC_type_main, ""));
@@ -281,10 +280,10 @@ VSC_Main(struct VSM_data *vd, struct VSM_fantom *fantom)
*/
void *
-VSC_Get(struct VSM_data *vd, struct VSM_fantom *fantom, const char *type,
+VSC_Get(const struct VSM_data *vd, struct VSM_fantom *fantom, const char *type,
const char *ident)
{
- struct VSM_fantom f2;
+ struct VSM_fantom f2 = VSM_FANTOM_NULL;
if (fantom == NULL)
fantom = &f2;
@@ -321,9 +320,10 @@ vsc_add_vf(struct vsc *vsc, const struct VSM_fantom *fantom,
VTAILQ_INSERT_TAIL(&vsc->vf_list, vf, list);
}
+/*lint -esym(528, vsc_add_pt) */
static void
vsc_add_pt(struct vsc *vsc, const volatile void *ptr,
- const struct VSC_desc *desc, struct vsc_vf *vf)
+ const struct VSC_desc *desc, const struct vsc_vf *vf)
{
struct vsc_pt *pt;
@@ -347,7 +347,7 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr,
CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); \
st = vf->fantom.b;
-#define VSC_F(nn,tt,ll,ff,vv,dd,ee) \
+#define VSC_F(nn,tt,ll,ff,vv,dd,ee) \
vsc_add_pt(vsc, &st->nn, descs++, vf);
#define VSC_DONE(U,l,t) \
diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index 501e19a..d7a5fa8 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -48,7 +48,6 @@
#include "vapi/vsm.h"
#include "vapi/vsl.h"
#include "vapi/vsm_int.h"
-#include "vin.h"
#include "vbm.h"
#include "vmb.h"
#include "vre.h"
@@ -154,7 +153,7 @@ VSL_ResetError(struct VSL_data *vsl)
}
static int
-vsl_match_IX(struct VSL_data *vsl, vslf_list *list, const struct VSL_cursor *c)
+vsl_match_IX(struct VSL_data *vsl, const vslf_list *list, const struct VSL_cursor *c)
{
enum VSL_tag_e tag;
const char *cdata;
@@ -202,7 +201,7 @@ VSL_Match(struct VSL_data *vsl, const struct VSL_cursor *c)
return (1);
}
-const char *VSL_transactions[256] = {
+static const char * const VSL_transactions[256] = {
/* 12345678901234 */
[VSL_t_unknown] = "<< Unknown >>",
[VSL_t_sess] = "<< Session >>",
@@ -219,7 +218,7 @@ const char *VSL_transactions[256] = {
} while (0)
int
-VSL_Print(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
+VSL_Print(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
{
enum VSL_tag_e tag;
uint32_t vxid;
@@ -257,7 +256,7 @@ VSL_Print(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
}
int
-VSL_PrintTerse(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
+VSL_PrintTerse(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
{
enum VSL_tag_e tag;
unsigned len;
@@ -390,7 +389,7 @@ VSL_WriteOpen(struct VSL_data *vsl, const char *name, int append, int unbuf)
}
int
-VSL_Write(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
+VSL_Write(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
{
size_t r;
More information about the varnish-commit
mailing list