Skip to content

Commit a18e511

Browse files
committed
fix several compile warnings
1 parent 4a3f7d7 commit a18e511

18 files changed

Lines changed: 48 additions & 91 deletions

backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int php_git2_backend_exists(git_odb_backend *_backend, const git_oid *oid
3333
TSRMLS_FETCH();
3434
zval *retval, *param;
3535
php_git2_backend_internal *m_backend;
36-
const char out[GIT_OID_HEXSZ+1] = {0};
36+
char out[GIT_OID_HEXSZ+1] = {0};
3737
int result = -1;
3838

3939
MAKE_STD_ZVAL(param);
@@ -93,7 +93,7 @@ static int php_git2_backend_read(void **buffer,size_t *size, git_otype *type, gi
9393
TSRMLS_FETCH();
9494
zval *retval, *z_oid, *z_type = NULL;
9595
php_git2_backend_internal *m_backend;
96-
const char out[GIT_OID_HEXSZ+1] = {0};
96+
char out[GIT_OID_HEXSZ+1] = {0};
9797
int result = GIT_ERROR;
9898

9999
MAKE_STD_ZVAL(z_oid);

blob.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ ZEND_END_ARG_INFO()
5555
*/
5656
PHP_METHOD(git2_blob, getContent)
5757
{
58-
char *data;
5958
php_git2_blob *m_blob;
6059

6160
m_blob = PHP_GIT2_GET_OBJECT(php_git2_blob, getThis());
@@ -78,7 +77,6 @@ PHP_METHOD(git2_blob, getContent)
7877
*/
7978
PHP_METHOD(git2_blob, getSize)
8079
{
81-
char *data;
8280
php_git2_blob *m_blob;
8381

8482
m_blob = PHP_GIT2_GET_OBJECT(php_git2_blob, getThis());
@@ -100,7 +98,6 @@ PHP_METHOD(git2_blob, getSize)
10098
*/
10199
PHP_METHOD(git2_blob, __toString)
102100
{
103-
char *data;
104101
php_git2_blob *m_blob;
105102

106103
m_blob = PHP_GIT2_GET_OBJECT(php_git2_blob, getThis());

commit.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ ZEND_END_ARG_INFO()
5858
*/
5959
PHP_METHOD(git2_commit, getMessage)
6060
{
61-
char *data;
6261
php_git2_commit *m_commit;
6362

6463
m_commit = PHP_GIT2_GET_OBJECT(php_git2_commit, getThis());
@@ -129,9 +128,8 @@ PHP_METHOD(git2_commit, parentCount)
129128
*/
130129
PHP_METHOD(git2_commit, getAuthor)
131130
{
132-
unsigned int parent_count = 0;
133131
php_git2_commit *m_commit;
134-
zval *z_signature, *date;
132+
zval *z_signature;
135133

136134
m_commit = PHP_GIT2_GET_OBJECT(php_git2_commit, getThis());
137135

@@ -153,9 +151,8 @@ PHP_METHOD(git2_commit, getAuthor)
153151
*/
154152
PHP_METHOD(git2_commit, getCommitter)
155153
{
156-
unsigned int parent_count = 0;
157154
php_git2_commit *m_commit;
158-
zval *z_signature, *date;
155+
zval *z_signature;
159156

160157
m_commit = PHP_GIT2_GET_OBJECT(php_git2_commit, getThis());
161158

@@ -177,10 +174,8 @@ PHP_METHOD(git2_commit, getCommitter)
177174
*/
178175
PHP_METHOD(git2_commit, getOid)
179176
{
180-
unsigned int parent_count = 0;
181177
php_git2_commit *m_commit;
182178
char oid_out[GIT_OID_HEXSZ] = {0};
183-
git_oid oid;
184179

185180
m_commit = PHP_GIT2_GET_OBJECT(php_git2_commit, getThis());
186181

@@ -210,7 +205,6 @@ PHP_METHOD(git2_commit, create)
210205
const git_commit **parents = NULL;
211206
git_commit **free_list = NULL;
212207
git_tree *tree;
213-
git_signature *author, *committer;
214208
git_oid commit_oid;
215209
char *message, *encoding, *ref, oid_out[GIT_OID_HEXSZ];
216210
int parent_count, i, error = 0;
@@ -344,7 +338,6 @@ PHP_METHOD(git2_commit, getTree)
344338
{
345339
php_git2_commit *m_commit;
346340
const git_oid *oid;
347-
git_oid *id;
348341
git_otype type = GIT_OBJ_TREE;
349342
git_object *object;
350343
zval *result;
@@ -412,7 +405,7 @@ PHP_METHOD(git2_commit, getParent)
412405
{
413406
php_git2_commit *m_commit;
414407
unsigned int parent_count = 0;
415-
int error, i = 0;
408+
int error = 0;
416409
long index = 0;
417410
zval *result;
418411
git_commit *parent = NULL;
@@ -455,9 +448,6 @@ PHP_METHOD(git2_commit, getParentCount)
455448
{
456449
php_git2_commit *m_commit;
457450
unsigned int parent_count = 0;
458-
int error, i = 0;
459-
zval *result;
460-
git_commit *parent = NULL;
461451

462452
m_commit = PHP_GIT2_GET_OBJECT(php_git2_commit, getThis());
463453

config.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ static void php_git2_config_free_storage(php_git2_config *object TSRMLS_DC)
4444
static int php_git2_config_has_dimension(zval *object, zval *member, int check_empty TSRMLS_DC)
4545
{
4646
zend_object_handlers *standard;
47-
HashTable *hash;
48-
zval *entry, *tmp_result, **target_offset;
47+
zval *entry, **target_offset;
4948
char *current_key, *tmp_value, *savedptr, *k;
50-
int error = 0;
5149

5250
entry = zend_read_property(git2_config_class_entry, object,"configs",sizeof("configs")-1, 0 TSRMLS_CC);
5351

@@ -92,8 +90,6 @@ static int php_git2_config_has_dimension(zval *object, zval *member, int check_e
9290
/* @todo refactoring */
9391
static zval* php_git2_config_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
9492
{
95-
zend_object_handlers *standard;
96-
HashTable *hash;
9793
zval *entry, *tmp_result, **target_offset;
9894
char *current_key, *tmp_value, *savedptr, *k;
9995
int error = 0;
@@ -172,7 +168,6 @@ typedef struct{
172168
static int php_git2_config_resolve(zval **result, const char *var_name, zval *m_config)
173169
{
174170
TSRMLS_FETCH();
175-
HashTable *hash;
176171
zval *entry, *tmp_result, **target_offset;
177172
char *current_key, *tmp_value, *savedptr, *k;
178173
int error = 0;
@@ -289,8 +284,7 @@ static int php_git2_config_reload(zval *object, unsigned short dtor TSRMLS_DC)
289284
static void php_git2_config_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC)
290285
{
291286
char *key;
292-
int error, key_len = 0;
293-
zval *result, *entry;
287+
int error = 0;
294288
php_git2_config *m_config;
295289

296290
m_config = PHP_GIT2_GET_OBJECT(php_git2_config, object);
@@ -325,8 +319,6 @@ PHP_METHOD(git2_config, __construct)
325319
git_config *config;
326320
int error, path_len = 0;
327321
php_git2_config *m_config;
328-
zval *config_array;
329-
php_git2_config_foreach_t payload;
330322

331323
/* @todo: supports array for reading multiple configs */
332324
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@@ -354,10 +346,7 @@ PHP_METHOD(git2_config, __construct)
354346
PHP_METHOD(git2_config, get)
355347
{
356348
char *key;
357-
git_config *config;
358-
int error, key_len = 0;
359-
const char *value;
360-
php_git2_config *m_config;
349+
int key_len = 0;
361350
zval *result;
362351

363352
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@@ -382,9 +371,8 @@ PHP_METHOD(git2_config, store)
382371
{
383372
char *key;
384373
int error, key_len = 0;
385-
zval *result, *value, *entry;
374+
zval *value;
386375
php_git2_config *m_config;
387-
php_git2_config_foreach_t payload;
388376

389377
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
390378
"sz", &key, &key_len, &value) == FAILURE) {
@@ -424,10 +412,8 @@ PHP_METHOD(git2_config, store)
424412
PHP_METHOD(git2_config, delete)
425413
{
426414
char *key;
427-
int error, key_len = 0;
428-
zval *result, *entry;
415+
int key_len = 0;
429416
php_git2_config *m_config;
430-
php_git2_config_foreach_t payload;
431417

432418
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
433419
"s", &key, &key_len) == FAILURE) {

git2.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,25 @@
2323
*/
2424

2525
#include "php_git2.h"
26+
#include "ext/standard/info.h"
2627

27-
extern void php_git2_repository_init(TSRMLS_D);
28-
extern void php_git2_commit_init(TSRMLS_D);
29-
extern void php_git2_blob_init(TSRMLS_D);
30-
extern void php_git2_tree_init(TSRMLS_D);
31-
extern void php_git2_tree_builder_init(TSRMLS_D);
32-
extern void php_git2_signature_init(TSRMLS_D);
33-
extern void php_git2_walker_init(TSRMLS_D);
34-
extern void php_git2_reference_init(TSRMLS_D);
35-
extern void php_git2_config_init(TSRMLS_D);
36-
extern void php_git2_remote_init(TSRMLS_D);
37-
extern void php_git2_tag_init(TSRMLS_D);
38-
extern void php_git2_odb_init(TSRMLS_D);
39-
extern void php_git2_odb_object_init(TSRMLS_D);
40-
28+
void php_git2_repository_init(TSRMLS_D);
29+
void php_git2_commit_init(TSRMLS_D);
30+
void php_git2_blob_init(TSRMLS_D);
31+
void php_git2_tree_init(TSRMLS_D);
32+
void php_git2_tree_builder_init(TSRMLS_D);
33+
void php_git2_signature_init(TSRMLS_D);
34+
void php_git2_walker_init(TSRMLS_D);
35+
void php_git2_reference_init(TSRMLS_D);
36+
void php_git2_config_init(TSRMLS_D);
37+
void php_git2_remote_init(TSRMLS_D);
38+
void php_git2_tag_init(TSRMLS_D);
39+
void php_git2_odb_init(TSRMLS_D);
40+
void php_git2_odb_object_init(TSRMLS_D);
41+
void php_git2_tree_entry_init(TSRMLS_D);
42+
void php_git2_index_entry_init(TSRMLS_D);
43+
void php_git2_backend_init(TSRMLS_D);
44+
void php_git2_index_init(TSRMLS_D);
4145

4246
int php_git2_call_user_function_v(zval **retval, zval *obj, char *method, unsigned int method_len, unsigned int param_count, ...)
4347
{
@@ -150,6 +154,12 @@ zval* php_git2_object_new(git_repository *repository, git_object *object TSRMLS_
150154

151155
break;
152156
}
157+
case GIT_OBJ_BAD:
158+
case GIT_OBJ_ANY:
159+
case GIT_OBJ__EXT1:
160+
case GIT_OBJ__EXT2:
161+
case GIT_OBJ_OFS_DELTA:
162+
case GIT_OBJ_REF_DELTA:
153163
default:
154164
break;
155165
}

index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ PHP_METHOD(git2_index, valid)
169169

170170
m_index = PHP_GIT2_GET_OBJECT(php_git2_index, getThis());
171171
entry_count = git_index_entrycount(m_index->index);
172-
if (m_index->offset < entry_count && m_index->offset >= 0) {
172+
if (m_index->offset < entry_count) {
173173
RETURN_TRUE;
174174
} else {
175175
RETURN_FALSE;

odb.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ PHP_METHOD(git2_odb, hash)
8383
char *contents;
8484
int contents_len = 0;
8585
long type = 0;
86-
git_odb *odb;
8786
git_oid oid;
8887
char oid_out[GIT_OID_HEXSZ+1];
8988
int error = 0;
@@ -112,7 +111,6 @@ PHP_METHOD(git2_odb, write)
112111
int contents_len = 0;
113112
long type = 0;
114113
git_odb_stream *stream;
115-
git_odb *odb;
116114
git_oid oid;
117115
char oid_out[GIT_OID_HEXSZ+1];
118116
int error = 0;
@@ -144,8 +142,7 @@ PHP_METHOD(git2_odb, write)
144142
PHP_METHOD(git2_odb, exists)
145143
{
146144
char *hash;
147-
int error, hash_len = 0;
148-
git_odb *odb;
145+
int hash_len = 0;
149146
git_oid id;
150147
php_git2_odb *m_odb;
151148

@@ -175,7 +172,6 @@ PHP_METHOD(git2_odb, read)
175172
{
176173
char *hash;
177174
int error, hash_len = 0;
178-
git_odb *odb;
179175
git_oid id;
180176
git_odb_object *object;
181177
zval *raw;

odb_object.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ zend_object_value php_git2_odb_object_new(zend_class_entry *ce TSRMLS_DC)
4848

4949
static int php_git2_odb_object_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC)
5050
{
51-
zval *retval;
5251
zend_class_entry *ce;
5352
php_git2_odb_object *m_raw;
5453

@@ -95,7 +94,6 @@ static int php_git2_odb_object_cast_object_tostring(zval *readobj, zval *writeob
9594
PHP_METHOD(git2_odb_object, getContent)
9695
{
9796
php_git2_odb_object *m_raw;
98-
git_otype type;
9997

10098
m_raw = PHP_GIT2_GET_OBJECT(php_git2_odb_object,getThis());
10199
RETVAL_STRINGL(git_odb_object_data(m_raw->object),git_odb_object_size(m_raw->object),1);

php_git2.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
# include "php.h"
3636
# include "Zend/zend_interfaces.h"
37+
# include "Zend/zend_exceptions.h"
3738
# include "ext/spl/spl_exceptions.h"
3839
# include <date/php_date.h>
3940
# include <git2.h>
@@ -212,10 +213,9 @@ static zval* php_git2_date_instantiate(zend_class_entry *pce, zval *object TSRML
212213
#endif
213214
}
214215

215-
static inline php_git2_create_signature_from_commit(zval **object, git_commit *commit, int type TSRMLS_DC)
216+
static void inline php_git2_create_signature_from_commit(zval **object, git_commit *commit, int type TSRMLS_DC)
216217
{
217-
zval *ret;
218-
zval *z_signature, *date;
218+
zval *ret, *date;
219219
char time_str[12] = {0};
220220
const git_signature *author;
221221
php_git2_signature *m_signature;

reference.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@ ZEND_END_ARG_INFO()
5959
PHP_METHOD(git2_reference, lookup)
6060
{
6161
char *path;
62-
char oid_out[GIT_OID_HEXSZ] = {0};
6362
int error, path_len = 0;
6463
git_reference *ref;
6564
zval *repository, *object;
66-
git_oid *oid;
6765
php_git2_repository *m_repository;
6866
php_git2_reference *m_reference;
6967

@@ -93,7 +91,6 @@ PHP_METHOD(git2_reference, lookup)
9391
*/
9492
PHP_METHOD(git2_reference, getTarget)
9593
{
96-
git_reference *ref;
9794
php_git2_reference *m_reference;
9895

9996
m_reference = PHP_GIT2_GET_OBJECT(php_git2_reference, getThis());
@@ -116,7 +113,6 @@ PHP_METHOD(git2_reference, getTarget)
116113
*/
117114
PHP_METHOD(git2_reference, getName)
118115
{
119-
git_reference *ref;
120116
php_git2_reference *m_reference;
121117

122118
m_reference = PHP_GIT2_GET_OBJECT(php_git2_reference, getThis());
@@ -130,10 +126,8 @@ PHP_METHOD(git2_reference, getName)
130126
*/
131127
PHP_METHOD(git2_reference, getBaseName)
132128
{
133-
git_reference *ref;
134-
zval *result;
129+
char *basename = NULL;
135130
const char *name = NULL;
136-
const *basename = NULL;
137131
php_git2_reference *m_reference;
138132
size_t len;
139133

@@ -231,12 +225,11 @@ static int php_git2_ref_foreach_cb(const char *name, void *opaque)
231225
*/
232226
PHP_METHOD(git2_reference, each)
233227
{
234-
git_reference *ref;
235-
zval *repository,*callback = NULL;
228+
zval *repository = NULL;
236229
php_git2_repository *m_repository;
237230
char *filter;
238231
php_git2_ref_foreach_cb_t opaque;
239-
int error, filter_len = 0;
232+
int filter_len = 0;
240233
unsigned int list_flags = GIT_REF_LISTALL;
241234
zend_fcall_info fci = {
242235
0,NULL,NULL,NULL,NULL,0,NULL,NULL

0 commit comments

Comments
 (0)