Fossil SCM
Replaced a few sprintf() calls with sqlite3_snprintf() to squish warnings from Clang on macOS when configured with extra debugging. (These warnings don't normally appear.) There is one left in extsrc/shell.c which needs fixing upstream.
Commit
dfa41afeab1581794389d0516688169081b53937f53541b85467efe9e65b82ad
Parent
9d0b52e2d244246…
2 files changed
+3
-3
+1
-1
+3
-3
| --- src/markdown_html.c | ||
| +++ src/markdown_html.c | ||
| @@ -402,11 +402,11 @@ | ||
| 402 | 402 | char pos[32]; |
| 403 | 403 | memset(pos,0,32); |
| 404 | 404 | assert( locus > 0 ); |
| 405 | 405 | /* expect BUGs if the following yields compiler warnings */ |
| 406 | 406 | if( iMark > 0 ){ /* a regular reference to a footnote */ |
| 407 | - sprintf(pos, "%s-%d-%s", ctx->unique.c, iMark, l.c); | |
| 407 | + sqlite3_snprintf(sizeof(pos), pos, "%s-%d-%s", ctx->unique.c, iMark, l.c); | |
| 408 | 408 | if(span && blob_size(span)) { |
| 409 | 409 | blob_append_literal(ob,"<span class='"); |
| 410 | 410 | append_footnote_upc(ob, upc, 0); |
| 411 | 411 | blob_append_literal(ob,"notescope' id='noteref"); |
| 412 | 412 | blob_appendf(ob,"%s'>",pos); |
| @@ -425,11 +425,11 @@ | ||
| 425 | 425 | pos, pos, iMark); |
| 426 | 426 | } |
| 427 | 427 | }else{ /* misreference */ |
| 428 | 428 | assert( iMark == -1 ); |
| 429 | 429 | |
| 430 | - sprintf(pos, "%s-%s", ctx->unique.c, l.c); | |
| 430 | + sqlite3_snprintf(sizeof(pos), pos, "%s-%s", ctx->unique.c, l.c); | |
| 431 | 431 | if(span && blob_size(span)) { |
| 432 | 432 | blob_appendf(ob, "<span class='notescope' id='misref%s'>", pos); |
| 433 | 433 | blob_appendb(ob, span); |
| 434 | 434 | blob_trim(ob); |
| 435 | 435 | blob_append_literal(ob, "<sup class='noteref misref'><a href='"); |
| @@ -485,11 +485,11 @@ | ||
| 485 | 485 | /* make.footnote_item() invocations should pass args accordingly */ |
| 486 | 486 | const struct Blob *upc = text+1; |
| 487 | 487 | assert( text ); |
| 488 | 488 | /* allow blob_size(text)==0 for constructs like [...](^ [] ()) */ |
| 489 | 489 | memset(pos,0,24); |
| 490 | - sprintf(pos, "%s-%d", unique, iMark); | |
| 490 | + sqlite3_snprintf(sizeof(pos), pos, "%s-%d", unique, iMark); | |
| 491 | 491 | blob_appendf(ob, "<li id='footnote%s' class='", pos); |
| 492 | 492 | if( nUsed ){ |
| 493 | 493 | if( blob_size(text)>=_jfi_sz && |
| 494 | 494 | !memcmp(blob_buffer(text),_joined_footnote_indicator,_jfi_sz)){ |
| 495 | 495 | bJoin = 1; |
| 496 | 496 |
| --- src/markdown_html.c | |
| +++ src/markdown_html.c | |
| @@ -402,11 +402,11 @@ | |
| 402 | char pos[32]; |
| 403 | memset(pos,0,32); |
| 404 | assert( locus > 0 ); |
| 405 | /* expect BUGs if the following yields compiler warnings */ |
| 406 | if( iMark > 0 ){ /* a regular reference to a footnote */ |
| 407 | sprintf(pos, "%s-%d-%s", ctx->unique.c, iMark, l.c); |
| 408 | if(span && blob_size(span)) { |
| 409 | blob_append_literal(ob,"<span class='"); |
| 410 | append_footnote_upc(ob, upc, 0); |
| 411 | blob_append_literal(ob,"notescope' id='noteref"); |
| 412 | blob_appendf(ob,"%s'>",pos); |
| @@ -425,11 +425,11 @@ | |
| 425 | pos, pos, iMark); |
| 426 | } |
| 427 | }else{ /* misreference */ |
| 428 | assert( iMark == -1 ); |
| 429 | |
| 430 | sprintf(pos, "%s-%s", ctx->unique.c, l.c); |
| 431 | if(span && blob_size(span)) { |
| 432 | blob_appendf(ob, "<span class='notescope' id='misref%s'>", pos); |
| 433 | blob_appendb(ob, span); |
| 434 | blob_trim(ob); |
| 435 | blob_append_literal(ob, "<sup class='noteref misref'><a href='"); |
| @@ -485,11 +485,11 @@ | |
| 485 | /* make.footnote_item() invocations should pass args accordingly */ |
| 486 | const struct Blob *upc = text+1; |
| 487 | assert( text ); |
| 488 | /* allow blob_size(text)==0 for constructs like [...](^ [] ()) */ |
| 489 | memset(pos,0,24); |
| 490 | sprintf(pos, "%s-%d", unique, iMark); |
| 491 | blob_appendf(ob, "<li id='footnote%s' class='", pos); |
| 492 | if( nUsed ){ |
| 493 | if( blob_size(text)>=_jfi_sz && |
| 494 | !memcmp(blob_buffer(text),_joined_footnote_indicator,_jfi_sz)){ |
| 495 | bJoin = 1; |
| 496 |
| --- src/markdown_html.c | |
| +++ src/markdown_html.c | |
| @@ -402,11 +402,11 @@ | |
| 402 | char pos[32]; |
| 403 | memset(pos,0,32); |
| 404 | assert( locus > 0 ); |
| 405 | /* expect BUGs if the following yields compiler warnings */ |
| 406 | if( iMark > 0 ){ /* a regular reference to a footnote */ |
| 407 | sqlite3_snprintf(sizeof(pos), pos, "%s-%d-%s", ctx->unique.c, iMark, l.c); |
| 408 | if(span && blob_size(span)) { |
| 409 | blob_append_literal(ob,"<span class='"); |
| 410 | append_footnote_upc(ob, upc, 0); |
| 411 | blob_append_literal(ob,"notescope' id='noteref"); |
| 412 | blob_appendf(ob,"%s'>",pos); |
| @@ -425,11 +425,11 @@ | |
| 425 | pos, pos, iMark); |
| 426 | } |
| 427 | }else{ /* misreference */ |
| 428 | assert( iMark == -1 ); |
| 429 | |
| 430 | sqlite3_snprintf(sizeof(pos), pos, "%s-%s", ctx->unique.c, l.c); |
| 431 | if(span && blob_size(span)) { |
| 432 | blob_appendf(ob, "<span class='notescope' id='misref%s'>", pos); |
| 433 | blob_appendb(ob, span); |
| 434 | blob_trim(ob); |
| 435 | blob_append_literal(ob, "<sup class='noteref misref'><a href='"); |
| @@ -485,11 +485,11 @@ | |
| 485 | /* make.footnote_item() invocations should pass args accordingly */ |
| 486 | const struct Blob *upc = text+1; |
| 487 | assert( text ); |
| 488 | /* allow blob_size(text)==0 for constructs like [...](^ [] ()) */ |
| 489 | memset(pos,0,24); |
| 490 | sqlite3_snprintf(sizeof(pos), pos, "%s-%d", unique, iMark); |
| 491 | blob_appendf(ob, "<li id='footnote%s' class='", pos); |
| 492 | if( nUsed ){ |
| 493 | if( blob_size(text)>=_jfi_sz && |
| 494 | !memcmp(blob_buffer(text),_joined_footnote_indicator,_jfi_sz)){ |
| 495 | bJoin = 1; |
| 496 |
+1
-1
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -795,11 +795,11 @@ | ||
| 795 | 795 | } |
| 796 | 796 | Th_MaybeStore("current_feature", feature_from_page_path(local_zCurrentPage) ); |
| 797 | 797 | if( g.ftntsIssues[0] || g.ftntsIssues[1] || |
| 798 | 798 | g.ftntsIssues[2] || g.ftntsIssues[3] ){ |
| 799 | 799 | char buf[80]; |
| 800 | - sprintf(&buf[0],"%i %i %i %i",g.ftntsIssues[0],g.ftntsIssues[1], | |
| 800 | + sqlite3_snprintf(sizeof(buf),buf,"%i %i %i %i",g.ftntsIssues[0],g.ftntsIssues[1], | |
| 801 | 801 | g.ftntsIssues[2],g.ftntsIssues[3]); |
| 802 | 802 | Th_Store("footnotes_issues_counters", buf); |
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -795,11 +795,11 @@ | |
| 795 | } |
| 796 | Th_MaybeStore("current_feature", feature_from_page_path(local_zCurrentPage) ); |
| 797 | if( g.ftntsIssues[0] || g.ftntsIssues[1] || |
| 798 | g.ftntsIssues[2] || g.ftntsIssues[3] ){ |
| 799 | char buf[80]; |
| 800 | sprintf(&buf[0],"%i %i %i %i",g.ftntsIssues[0],g.ftntsIssues[1], |
| 801 | g.ftntsIssues[2],g.ftntsIssues[3]); |
| 802 | Th_Store("footnotes_issues_counters", buf); |
| 803 | } |
| 804 | } |
| 805 | |
| 806 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -795,11 +795,11 @@ | |
| 795 | } |
| 796 | Th_MaybeStore("current_feature", feature_from_page_path(local_zCurrentPage) ); |
| 797 | if( g.ftntsIssues[0] || g.ftntsIssues[1] || |
| 798 | g.ftntsIssues[2] || g.ftntsIssues[3] ){ |
| 799 | char buf[80]; |
| 800 | sqlite3_snprintf(sizeof(buf),buf,"%i %i %i %i",g.ftntsIssues[0],g.ftntsIssues[1], |
| 801 | g.ftntsIssues[2],g.ftntsIssues[3]); |
| 802 | Th_Store("footnotes_issues_counters", buf); |
| 803 | } |
| 804 | } |
| 805 | |
| 806 |