Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Mark functions that never return (ex: fossil_panic()) as such so that static analyzers can do a better job of pruning paths. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
86d2b4efc8367e5300baa613ef13d092 |
| User & Date: | drh 2011-10-15 12:16:04.014 |
Context
|
2011-10-15
| ||
| 12:30 | Fix clang static analyzer warnings about deref null pointers and undefined values. There are still lots of dead code warnings, but those are harmless. ... (check-in: 630691456b user: drh tags: trunk) | |
| 12:16 | Mark functions that never return (ex: fossil_panic()) as such so that static analyzers can do a better job of pruning paths. ... (check-in: 86d2b4efc8 user: drh tags: trunk) | |
| 10:40 | Update the built-in SQLite and the SQL command-line shell to the latest code from the SQLite trunk: version 3.7.9 alpha. This fixes some warnings that started appearing after upgrading to gcc 4.6.1. ... (check-in: 3dd0c15583 user: drh tags: trunk) | |
Changes
Changes to src/cgi.c.
| ︙ | ︙ | |||
360 361 362 363 364 365 366 | } /* ** Do a redirect request to the URL given in the argument. ** ** The URL must be relative to the base of the fossil server. */ | | | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
}
/*
** Do a redirect request to the URL given in the argument.
**
** The URL must be relative to the base of the fossil server.
*/
NORETURN void cgi_redirect(const char *zURL){
char *zLocation;
CGIDEBUG(("redirect to %s\n", zURL));
if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 ){
zLocation = mprintf("Location: %s\r\n", zURL);
}else if( *zURL=='/' ){
zLocation = mprintf("Location: %.*s%s\r\n",
strlen(g.zBaseURL)-strlen(g.zTop), g.zBaseURL, zURL);
}else{
zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL);
}
cgi_append_header(zLocation);
cgi_reset_content();
cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zLocation);
cgi_set_status(302, "Moved Temporarily");
free(zLocation);
cgi_reply();
fossil_exit(0);
}
NORETURN void cgi_redirectf(const char *zFormat, ...){
va_list ap;
va_start(ap, zFormat);
cgi_redirect(vmprintf(zFormat, ap));
va_end(ap);
}
/*
|
| ︙ | ︙ | |||
925 926 927 928 929 930 931 | vxprintf(pContent,zFormat,ap); } /* ** Send a reply indicating that the HTTP request was malformed */ | | | | 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 |
vxprintf(pContent,zFormat,ap);
}
/*
** Send a reply indicating that the HTTP request was malformed
*/
static NORETURN void malformed_request(void){
cgi_set_status(501, "Not Implemented");
cgi_printf(
"<html><body>Unrecognized HTTP Request</body></html>\n"
);
cgi_reply();
fossil_exit(0);
}
/*
** Panic and die while processing a webpage.
*/
NORETURN void cgi_panic(const char *zFormat, ...){
va_list ap;
cgi_reset_content();
cgi_set_status(500, "Internal Server Error");
cgi_printf(
"<html><body><h1>Internal Server Error</h1>\n"
"<plaintext>"
);
|
| ︙ | ︙ |
Changes to src/config.h.
| ︙ | ︙ | |||
132 133 134 135 136 137 138 139 | # define FOSSIL_INT_TO_PTR(X) ((void*)&((char*)0)[X]) # define FOSSIL_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) #else /* Generates a warning - but it always works */ # define FOSSIL_INT_TO_PTR(X) ((void*)(X)) # define FOSSIL_PTR_TO_INT(X) ((int)(X)) #endif #endif /* _RC_COMPILE_ */ | > > > > > > > > > | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | # define FOSSIL_INT_TO_PTR(X) ((void*)&((char*)0)[X]) # define FOSSIL_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) #else /* Generates a warning - but it always works */ # define FOSSIL_INT_TO_PTR(X) ((void*)(X)) # define FOSSIL_PTR_TO_INT(X) ((int)(X)) #endif /* ** A marker for functions that never return. */ #if defined(__GNUC__) || defined(__clang__) # define NORETURN __attribute__((__noreturn__)) #else # define NORETURN #endif #endif /* _RC_COMPILE_ */ |
Changes to src/main.c.
| ︙ | ︙ | |||
398 399 400 401 402 403 404 | return g.argv[0]; #endif } /* ** Exit. Take care to close the database first. */ | | | | | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
return g.argv[0];
#endif
}
/*
** Exit. Take care to close the database first.
*/
NORETURN void fossil_exit(int rc){
db_close(1);
exit(rc);
}
/*
** Print an error message, rollback all databases, and quit. These
** routines never return.
*/
NORETURN void fossil_panic(const char *zFormat, ...){
char *z;
va_list ap;
static int once = 1;
mainInFatalError = 1;
va_start(ap, zFormat);
z = vmprintf(zFormat, ap);
va_end(ap);
if( g.cgiOutput && once ){
once = 0;
cgi_printf("<p class=\"generalError\">%h</p>", z);
cgi_reply();
}else{
char *zOut = mprintf("%s: %s\n", fossil_nameofexe(), z);
fossil_puts(zOut, 1);
}
db_force_rollback();
fossil_exit(1);
}
NORETURN void fossil_fatal(const char *zFormat, ...){
char *z;
va_list ap;
mainInFatalError = 1;
va_start(ap, zFormat);
z = vmprintf(zFormat, ap);
va_end(ap);
if( g.cgiOutput ){
|
| ︙ | ︙ | |||
914 915 916 917 918 919 920 |
g.zTop = &g.zBaseURL[7+strlen(zHost)];
}
}
/*
** Send an HTTP redirect back to the designated Index Page.
*/
| | | 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 |
g.zTop = &g.zBaseURL[7+strlen(zHost)];
}
}
/*
** Send an HTTP redirect back to the designated Index Page.
*/
NORETURN void fossil_redirect_home(void){
cgi_redirectf("%s%s", g.zTop, db_get("index-page", "/index"));
}
/*
** If running as root, chroot to the directory containing the
** repository zRepo and then drop root privileges. Return the
** new repository name.
|
| ︙ | ︙ |