Re: [bugzcxx-devel] few more changes to silent gcc and add compiler flags
Status: Alpha
Brought to you by:
mindstorm2600
From: BugzCXX D. <bug...@li...> - 2010-01-18 06:09:08
|
Excelent my friend, the new compiler flags helped me to fix my weak safe_getpass() function. Kudos On Fri, Jan 15, 2010 at 7:23 AM, BugzCXX Developers < bug...@li...> wrote: > For information I just pushed one more patch which will make out code > base extra sane. In case something breaks up please ping me, but > assurances that I try to keep every patch consistent and trunk safe. > But it is devel so it has to bleeding ;) > > I have set on the Werror flag so that every silly mistake will get > caught sooner then later. In short following changes were done: > > 1. Made "-D_GNU_SOURCE -Wall -Wshadow -Wunused -Wextra -Werror > -Wformat=2" as compiler flags. Suggested for standard projects. > Switched on Werror which will help keeping quality of code ;) > 2. Fixed implicit references to functions from xmlrpc_helper file. > 3. Removed unused variables. > 4. Fixed implicit declaration of strptime function. > 5. Commented out validate_url for later development and removed its > (not so sane) usage from init functions. > 6. Fixed wrongly declared static variable in bugzc/bugzc_product.c . > 7. Renamed timezone in examples/bugzc/gettimezone.c to time_zone > because it was shadowning declarations from time.h > 8. Fixed return value for bugzc_list_create from bugzc/bugzc_list.c. > > -- > Rakesh Pandit > https://fedoraproject.org/wiki/User:Rakesh > freedom, friends, features, first > > > Index: configure.ac > =================================================================== > --- configure.ac (revision 37) > +++ configure.ac (working copy) > @@ -64,7 +64,9 @@ > AC_PROG_INSTALL > AC_LANG_CPLUSPLUS > > -CXXFLAGS="$CXXFLAGS -Wall " > +COMPILER_FLAGS="-D_GNU_SOURCE -Wall -Wshadow -Wunused -Wextra -Werror > -Wformat=2" > +CXXFLAGS="$CXXFLAGS $COMPILER_FLAGS " > +CFLAGS="$CFLAGS $COMPILER_FLAGS " > > dnl ----------------------------------------------- > dnl Verify manual features > Index: bugzc/bugzc_bugzilla.c > =================================================================== > --- bugzc/bugzc_bugzilla.c (revision 37) > +++ bugzc/bugzc_bugzilla.c (working copy) > @@ -12,6 +12,7 @@ > > #include"config.h" > #include<bugzc/bugzc_bugzilla.h> > +#include<bugzc/xmlrpc_helper.h> > #include<string.h> > > extern const char *_bugz_errmsg[]; > Index: bugzc/xmlrpc_helper.c > =================================================================== > --- bugzc/xmlrpc_helper.c (revision 37) > +++ bugzc/xmlrpc_helper.c (working copy) > @@ -132,7 +132,6 @@ > const char *param, > const char *s){ > int ret = 0; > - char *tmp_ret; > xmlrpc_value *result = 0; > #ifdef RESPONSE_TIME_DEBUGGING > struct timeval t1, t2, tr; > Index: bugzc/bugzc_list.c > =================================================================== > --- bugzc/bugzc_list.c (revision 37) > +++ bugzc/bugzc_list.c (working copy) > @@ -52,6 +52,7 @@ > list->first = 0; > list->last = 0; > list->count = 0; > + return list; > } > > void bugzc_list_free(bugzc_list *list){ > Index: bugzc/bugzc_bug.c > =================================================================== > --- bugzc/bugzc_bug.c (revision 37) > +++ bugzc/bugzc_bug.c (working copy) > @@ -15,7 +15,9 @@ > #include"bugz_errcodes.h" > #include<string.h> > #include<stdlib.h> > +#ifndef _XOPEN_SOURCE > #define _XOPEN_SOURCE > +#endif > #include<time.h> > > extern const char *_bugz_errmsg[]; > @@ -26,7 +28,7 @@ > size_t max_vsize) > { > int ret = -1; > - int r_nitems; > + size_t r_nitems; > int i; > xmlrpc_value *result; > xmlrpc_value *v_list; > @@ -86,7 +88,7 @@ > } > else{ > ret = r_nitems; > - for(i = 0; i < r_nitems; i++){ > + for(i = 0; i < (int)r_nitems; i++){ > xmlrpc_array_read_item(&bconn->xenv, v_list, > i, &tmp_val); > xmlrpc_decompose_value(&bconn->xenv, > tmp_val, > @@ -308,12 +310,7 @@ > const char *op_sys, const char *platform, > const char *priority, const char *severity){ > int ret = -1; > - int r_nitems; > - int i; > xmlrpc_value *result; > - xmlrpc_value *v_list; > - xmlrpc_value *tmp_val; > - char *tmp_item_value; > if(bconn->url == 0){ > bconn->err_msg = (char > *)_bugz_errmsg[BUGZCXX_NO_INITIALIZED]; > bconn->err_code = BUGZCXX_NO_INITIALIZED; > @@ -408,20 +405,14 @@ > bugzc_bug *bugzc_bug_get_bugs(bugzc_conn *bconn, unsigned int *bug_ids, > size_t nbugid, size_t *rbugid){ > bugzc_bug *ret = 0; > - int r_nitems; > int i; > xmlrpc_value *result; > - xmlrpc_value *v_list; > - xmlrpc_value *tmp_val; > xmlrpc_value *int_array; > xmlrpc_value *int_item; > xmlrpc_value *bug_array; > xmlrpc_value *bug_item; > - xmlrpc_value *ctime; > - xmlrpc_value *lctime; > char *b_summary; > char *b_alias; > - char *tmp_str; > char *b_ctime; > char *b_lctime; > struct tm tmp_tm; > @@ -431,7 +422,7 @@ > return 0; > } > int_array = xmlrpc_array_new(&bconn->xenv); > - for(i = 0; i < nbugid; i++){ > + for(i = 0; i < (int)nbugid; i++){ > int_item = xmlrpc_build_value(&bconn->xenv, "i", > bug_ids[i]); > xmlrpc_array_append_item(&bconn->xenv, int_array, int_item); > } > @@ -486,7 +477,7 @@ > "{s:A,*}", "bugs", &bug_array); > *rbugid = xmlrpc_array_size(&bconn->xenv, bug_array); > ret = malloc(sizeof(bugzc_bug) * *rbugid); > - for(i = 0; i < *rbugid; i++){ > + for(i = 0; i < (int)*rbugid; i++){ > xmlrpc_array_read_item(&bconn->xenv, bug_array, i, > &bug_item); > xmlrpc_decompose_value(&bconn->xenv, bug_item, > "{s:s,s:i,s:s,s:8,s:8,*}", > @@ -521,20 +512,14 @@ > int bugzc_bug_get_bugs_list(bugzc_conn *bconn, unsigned int *bug_ids, > size_t nbugid, bugzc_list *olist){ > int ret = -1; > - int r_nitems; > int i, tmp_id; > xmlrpc_value *result; > - xmlrpc_value *v_list; > - xmlrpc_value *tmp_val; > xmlrpc_value *int_array; > xmlrpc_value *int_item; > xmlrpc_value *bug_array; > xmlrpc_value *bug_item; > - xmlrpc_value *ctime; > - xmlrpc_value *lctime; > char *b_summary; > char *b_alias; > - char *tmp_str; > char *b_ctime; > char *b_lctime; > bugzc_bug *bug_obj; > @@ -545,7 +530,7 @@ > } > bugzc_list_create(olist); > int_array = xmlrpc_array_new(&bconn->xenv); > - for(i = 0; i < nbugid; i++){ > + for(i = 0; i < (int)nbugid; i++){ > int_item = xmlrpc_build_value(&bconn->xenv, "i", > bug_ids[i]); > xmlrpc_array_append_item(&bconn->xenv, int_array, int_item); > } > Index: bugzc/bugzc_user.c > =================================================================== > --- bugzc/bugzc_user.c (revision 37) > +++ bugzc/bugzc_user.c (working copy) > @@ -13,6 +13,7 @@ > #include"config.h" > #include"bugzc_user.h" > #include"bugz_errcodes.h" > +#include<bugzc/xmlrpc_helper.h> > #ifdef RESPONSE_TIME_DEBUGGING > #include<sys/time.h> > #include<stdio.h> > Index: bugzc/bugzc_product.c > =================================================================== > --- bugzc/bugzc_product.c (revision 37) > +++ bugzc/bugzc_product.c (working copy) > @@ -59,7 +59,7 @@ > "ids", > olist); > } > > -const static char *pp[] = { > +static const char *pp[] = { > "id", > "name", > "description" > @@ -75,7 +75,6 @@ > xmlrpc_value *int_array; > xmlrpc_value *int_item; > int i, _id; > - int *val_s; > char *_name, *_description; > bugzc_product *tmp_product; > bugzc_list_create(olist); > Index: bugzc/bugzc.c > =================================================================== > --- bugzc/bugzc.c (revision 37) > +++ bugzc/bugzc.c (working copy) > @@ -23,22 +23,18 @@ > > static const char *__curl_transport = "curl"; > > > -/***************************************************************************/ > -static int validate_url(const char *url, size_t surl){ > - /** @todo: Write a function that can validate urls */ > - /* regex: http[s]?:\/\/[a-zA-Z0-9]*{\.[a-zA-Z0-9].....*/ > - return 1; > -} > +/* @todo: Write a function that can validate urls */ > +/* static int validate_url(const char *url, size_t surl){ */ > +/* /\* regex: http[s]?:\/\/[a-zA-Z0-9]*{\.[a-zA-Z0-9].....*\/ */ > +/* return 1; */ > +/* } */ > > static struct xmlrpc_clientparms global_xparms; > > int bugzc_init(bugzc_conn *bc, const char *url, size_t surl){ > bc->err_code = 0; > bc->err_msg = 0; > - if(!validate_url(url, surl)){ > - bc->url = 0; > - return -1; > - } > + /* Validate url using validate_url when it is written */ > bc->url = malloc(surl + 1); > strncpy(bc->url, url, surl); > bc->url[surl] = '\0'; > @@ -58,10 +54,7 @@ > bc->err_code = 0; > bc->err_msg = 0; > surl = strlen(url); > - if(!validate_url(url, surl)){ > - bc->url = 0; > - return -1; > - } > + /* Validate url using validate_url when it is written */ > bc->url = malloc(surl + 1); > strncpy(bc->url, url, surl); > bc->url[surl] = '\0'; > Index: examples/bugzc/gettimezone.c > =================================================================== > --- examples/bugzc/gettimezone.c (revision 37) > +++ examples/bugzc/gettimezone.c (working copy) > @@ -17,7 +17,7 @@ > > int main(int argc, char *argv[]){ > char *url; > - char timezone[36]; > + char time_zone[36]; > > bugzc_conn conn; > url = argv[1]; > @@ -34,7 +34,7 @@ > fprintf(stderr, "%s\n", conn.xenv.fault_string); > return 1; > } > - if(bugzc_bugzilla_timezone(&conn, timezone, 36) < 0){ > + if(bugzc_bugzilla_timezone(&conn, time_zone, 36) < 0){ > if(conn.err_code != 0){ > fprintf(stderr, "\n"); > if(conn.xenv.fault_occurred){ > @@ -47,7 +47,7 @@ > } > return 1; > } > - printf("is %s\n", timezone); > + printf("is %s\n", time_zone); > > return 0; > } > > > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for > Conference > attendees to learn about information security's most important issues > through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Bugzcxx-devel mailing list > Bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugzcxx-devel > -- In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite. -- Paul A. M. Dirac |