Fossil SCM

gcc warnings: <pre>src/merge3.c: In function ‘merge_3way’: src/merge3.c:445:9: warning: ‘zPivot’ may be used uninitialized in this function src/merge3.c:446:9: warning: ‘zOrig’ may be used uninitialized in this function src/merge3.c:447:9: warning: ‘zOther’ may be used uninitialized in this function </pre>

jan.nijtmans 2012-11-06 12:20 trunk
Commit 233463c4ec13c1be7e89748caf034cd5e293c5ab
1 file changed +34 -35
+34 -35
--- src/merge3.c
+++ src/merge3.c
@@ -59,11 +59,11 @@
5959
6060
/*
6161
** Look at the next edit triple in both aC1 and aC2. (An "edit triple" is
6262
** three integers describing the number of copies, deletes, and inserts in
6363
** moving from the original to the edited copy of the file.) If the three
64
-** integers of the edit triples describe an identical edit, then return 1.
64
+** integers of the edit triples describe an identical edit, then return 1.
6565
** If the edits are different, return 0.
6666
*/
6767
static int sameEdit(
6868
int *aC1, /* Array of edit integers for file 1 */
6969
int *aC2, /* Array of edit integers for file 2 */
@@ -154,11 +154,11 @@
154154
** common origin at pPivot. Apply the changes of pPivot ==> pV1
155155
** to pV2.
156156
**
157157
** The return is 0 upon complete success. If any input file is binary,
158158
** -1 is returned and pOut is unmodified. If there are merge
159
-** conflicts, the merge proceeds as best as it can and the number
159
+** conflicts, the merge proceeds as best as it can and the number
160160
** of conflicts is returns
161161
*/
162162
static int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
163163
int *aC1; /* Changes from pPivot to pV1 */
164164
int *aC2; /* Changes from pPivot to pV2 */
@@ -440,55 +440,54 @@
440440
Blob *pOut, /* Output written here */
441441
unsigned mergeFlags /* Flags that control operation */
442442
){
443443
Blob v1; /* Content of zV1 */
444444
int rc; /* Return code of subroutines and this routine */
445
- char *zPivot; /* Name of the pivot file */
446
- char *zOrig; /* Name of the original content file */
447
- char *zOther; /* Name of the merge file */
448445
449446
blob_read_from_file(&v1, zV1);
450447
rc = blob_merge(pPivot, &v1, pV2, pOut);
451448
if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
449
+ char *zPivot; /* Name of the pivot file */
450
+ char *zOrig; /* Name of the original content file */
451
+ char *zOther; /* Name of the merge file */
452
+
452453
zPivot = file_newname(zV1, "baseline", 1);
453454
blob_write_to_file(pPivot, zPivot);
454455
zOrig = file_newname(zV1, "original", 1);
455456
blob_write_to_file(&v1, zOrig);
456457
zOther = file_newname(zV1, "merge", 1);
457458
blob_write_to_file(pV2, zOther);
458
- }
459
- if( rc>0 && (mergeFlags & MERGE_DRYRUN)==0 ){
460
- const char *zGMerge; /* Name of the gmerge command */
461
-
462
- zGMerge = db_get("gmerge-command", 0);
463
- if( zGMerge && zGMerge[0] ){
464
- char *zOut; /* Temporary output file */
465
- char *zCmd; /* Command to invoke */
466
- const char *azSubst[8]; /* Strings to be substituted */
467
-
468
- zOut = file_newname(zV1, "output", 1);
469
- azSubst[0] = "%baseline"; azSubst[1] = zPivot;
470
- azSubst[2] = "%original"; azSubst[3] = zOrig;
471
- azSubst[4] = "%merge"; azSubst[5] = zOther;
472
- azSubst[6] = "%output"; azSubst[7] = zOut;
473
- zCmd = string_subst(zGMerge, 8, azSubst);
474
- printf("%s\n", zCmd); fflush(stdout);
475
- fossil_system(zCmd);
476
- if( file_wd_size(zOut)>=0 ){
477
- blob_read_from_file(pOut, zOut);
478
- file_delete(zPivot);
479
- file_delete(zOrig);
480
- file_delete(zOther);
481
- file_delete(zOut);
482
- }
483
- fossil_free(zCmd);
484
- fossil_free(zOut);
485
- }
486
- }
487
- if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
459
+ if( rc>0 ){
460
+ const char *zGMerge; /* Name of the gmerge command */
461
+
462
+ zGMerge = db_get("gmerge-command", 0);
463
+ if( zGMerge && zGMerge[0] ){
464
+ char *zOut; /* Temporary output file */
465
+ char *zCmd; /* Command to invoke */
466
+ const char *azSubst[8]; /* Strings to be substituted */
467
+
468
+ zOut = file_newname(zV1, "output", 1);
469
+ azSubst[0] = "%baseline"; azSubst[1] = zPivot;
470
+ azSubst[2] = "%original"; azSubst[3] = zOrig;
471
+ azSubst[4] = "%merge"; azSubst[5] = zOther;
472
+ azSubst[6] = "%output"; azSubst[7] = zOut;
473
+ zCmd = string_subst(zGMerge, 8, azSubst);
474
+ printf("%s\n", zCmd); fflush(stdout);
475
+ fossil_system(zCmd);
476
+ if( file_wd_size(zOut)>=0 ){
477
+ blob_read_from_file(pOut, zOut);
478
+ file_delete(zPivot);
479
+ file_delete(zOrig);
480
+ file_delete(zOther);
481
+ file_delete(zOut);
482
+ }
483
+ fossil_free(zCmd);
484
+ fossil_free(zOut);
485
+ }
486
+ }
488487
fossil_free(zPivot);
489488
fossil_free(zOrig);
490489
fossil_free(zOther);
491490
}
492491
blob_reset(&v1);
493492
return rc;
494493
}
495494
--- src/merge3.c
+++ src/merge3.c
@@ -59,11 +59,11 @@
59
60 /*
61 ** Look at the next edit triple in both aC1 and aC2. (An "edit triple" is
62 ** three integers describing the number of copies, deletes, and inserts in
63 ** moving from the original to the edited copy of the file.) If the three
64 ** integers of the edit triples describe an identical edit, then return 1.
65 ** If the edits are different, return 0.
66 */
67 static int sameEdit(
68 int *aC1, /* Array of edit integers for file 1 */
69 int *aC2, /* Array of edit integers for file 2 */
@@ -154,11 +154,11 @@
154 ** common origin at pPivot. Apply the changes of pPivot ==> pV1
155 ** to pV2.
156 **
157 ** The return is 0 upon complete success. If any input file is binary,
158 ** -1 is returned and pOut is unmodified. If there are merge
159 ** conflicts, the merge proceeds as best as it can and the number
160 ** of conflicts is returns
161 */
162 static int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
163 int *aC1; /* Changes from pPivot to pV1 */
164 int *aC2; /* Changes from pPivot to pV2 */
@@ -440,55 +440,54 @@
440 Blob *pOut, /* Output written here */
441 unsigned mergeFlags /* Flags that control operation */
442 ){
443 Blob v1; /* Content of zV1 */
444 int rc; /* Return code of subroutines and this routine */
445 char *zPivot; /* Name of the pivot file */
446 char *zOrig; /* Name of the original content file */
447 char *zOther; /* Name of the merge file */
448
449 blob_read_from_file(&v1, zV1);
450 rc = blob_merge(pPivot, &v1, pV2, pOut);
451 if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
 
 
 
 
452 zPivot = file_newname(zV1, "baseline", 1);
453 blob_write_to_file(pPivot, zPivot);
454 zOrig = file_newname(zV1, "original", 1);
455 blob_write_to_file(&v1, zOrig);
456 zOther = file_newname(zV1, "merge", 1);
457 blob_write_to_file(pV2, zOther);
458 }
459 if( rc>0 && (mergeFlags & MERGE_DRYRUN)==0 ){
460 const char *zGMerge; /* Name of the gmerge command */
461
462 zGMerge = db_get("gmerge-command", 0);
463 if( zGMerge && zGMerge[0] ){
464 char *zOut; /* Temporary output file */
465 char *zCmd; /* Command to invoke */
466 const char *azSubst[8]; /* Strings to be substituted */
467
468 zOut = file_newname(zV1, "output", 1);
469 azSubst[0] = "%baseline"; azSubst[1] = zPivot;
470 azSubst[2] = "%original"; azSubst[3] = zOrig;
471 azSubst[4] = "%merge"; azSubst[5] = zOther;
472 azSubst[6] = "%output"; azSubst[7] = zOut;
473 zCmd = string_subst(zGMerge, 8, azSubst);
474 printf("%s\n", zCmd); fflush(stdout);
475 fossil_system(zCmd);
476 if( file_wd_size(zOut)>=0 ){
477 blob_read_from_file(pOut, zOut);
478 file_delete(zPivot);
479 file_delete(zOrig);
480 file_delete(zOther);
481 file_delete(zOut);
482 }
483 fossil_free(zCmd);
484 fossil_free(zOut);
485 }
486 }
487 if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
488 fossil_free(zPivot);
489 fossil_free(zOrig);
490 fossil_free(zOther);
491 }
492 blob_reset(&v1);
493 return rc;
494 }
495
--- src/merge3.c
+++ src/merge3.c
@@ -59,11 +59,11 @@
59
60 /*
61 ** Look at the next edit triple in both aC1 and aC2. (An "edit triple" is
62 ** three integers describing the number of copies, deletes, and inserts in
63 ** moving from the original to the edited copy of the file.) If the three
64 ** integers of the edit triples describe an identical edit, then return 1.
65 ** If the edits are different, return 0.
66 */
67 static int sameEdit(
68 int *aC1, /* Array of edit integers for file 1 */
69 int *aC2, /* Array of edit integers for file 2 */
@@ -154,11 +154,11 @@
154 ** common origin at pPivot. Apply the changes of pPivot ==> pV1
155 ** to pV2.
156 **
157 ** The return is 0 upon complete success. If any input file is binary,
158 ** -1 is returned and pOut is unmodified. If there are merge
159 ** conflicts, the merge proceeds as best as it can and the number
160 ** of conflicts is returns
161 */
162 static int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
163 int *aC1; /* Changes from pPivot to pV1 */
164 int *aC2; /* Changes from pPivot to pV2 */
@@ -440,55 +440,54 @@
440 Blob *pOut, /* Output written here */
441 unsigned mergeFlags /* Flags that control operation */
442 ){
443 Blob v1; /* Content of zV1 */
444 int rc; /* Return code of subroutines and this routine */
 
 
 
445
446 blob_read_from_file(&v1, zV1);
447 rc = blob_merge(pPivot, &v1, pV2, pOut);
448 if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
449 char *zPivot; /* Name of the pivot file */
450 char *zOrig; /* Name of the original content file */
451 char *zOther; /* Name of the merge file */
452
453 zPivot = file_newname(zV1, "baseline", 1);
454 blob_write_to_file(pPivot, zPivot);
455 zOrig = file_newname(zV1, "original", 1);
456 blob_write_to_file(&v1, zOrig);
457 zOther = file_newname(zV1, "merge", 1);
458 blob_write_to_file(pV2, zOther);
459 if( rc>0 ){
460 const char *zGMerge; /* Name of the gmerge command */
461
462 zGMerge = db_get("gmerge-command", 0);
463 if( zGMerge && zGMerge[0] ){
464 char *zOut; /* Temporary output file */
465 char *zCmd; /* Command to invoke */
466 const char *azSubst[8]; /* Strings to be substituted */
467
468 zOut = file_newname(zV1, "output", 1);
469 azSubst[0] = "%baseline"; azSubst[1] = zPivot;
470 azSubst[2] = "%original"; azSubst[3] = zOrig;
471 azSubst[4] = "%merge"; azSubst[5] = zOther;
472 azSubst[6] = "%output"; azSubst[7] = zOut;
473 zCmd = string_subst(zGMerge, 8, azSubst);
474 printf("%s\n", zCmd); fflush(stdout);
475 fossil_system(zCmd);
476 if( file_wd_size(zOut)>=0 ){
477 blob_read_from_file(pOut, zOut);
478 file_delete(zPivot);
479 file_delete(zOrig);
480 file_delete(zOther);
481 file_delete(zOut);
482 }
483 fossil_free(zCmd);
484 fossil_free(zOut);
485 }
486 }
 
 
487 fossil_free(zPivot);
488 fossil_free(zOrig);
489 fossil_free(zOther);
490 }
491 blob_reset(&v1);
492 return rc;
493 }
494

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button