From: <ai...@us...> - 2013-10-24 18:22:33
|
Revision: 12624 http://sourceforge.net/p/plplot/code/12624 Author: airwin Date: 2013-10-24 18:22:29 +0000 (Thu, 24 Oct 2013) Log Message: ----------- Fix bug in logic which allowed uninitialized values (for height, pos, and just) for the fairly common case when label_func and label_data were non-NULL. Improve code clarity so it is obvious these values must be initialized by the code logic. N.B. the gcc options -O3 -Wunintialized found this bug, but the above fix does not quiet the warning message, i.e., this bug fix turns this warning about uninitialized variables into a false alarm. Modified Paths: -------------- trunk/src/plbox.c Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2013-10-24 17:38:37 UTC (rev 12623) +++ trunk/src/plbox.c 2013-10-24 18:22:29 UTC (rev 12624) @@ -1400,6 +1400,10 @@ PLFLT default_mm, char_height_mm, height_mm; PLFLT string_length_mm = 0.0, pos_mm = 0.0; + // Assume label data is for placement of exponents if no custom + // label function is provided. + PLBOOL custom_exponent_placement = !plsc->label_func && plsc->label_data; + plgchr( &default_mm, &char_height_mm ); // Set plot options from input @@ -1526,9 +1530,7 @@ if ( !llx && !ldx && !lox && xmode ) { - // Assume label data is for placement of exponents if no custom - // label function is provided. - if ( !plsc->label_func && plsc->label_data ) + if ( custom_exponent_placement ) { height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; @@ -1770,7 +1772,7 @@ if ( !lly && !ldy && !loy && ymode ) { snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale ); - if ( !plsc->label_func && plsc->label_data ) + if ( custom_exponent_placement ) { height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; @@ -1787,7 +1789,7 @@ // Left axis exponent if ( lny ) { - if ( !plsc->label_data ) + if ( !custom_exponent_placement ) { height = 3.2; pos = 1.0 + offset; @@ -1825,7 +1827,7 @@ // Right axis exponent. if ( lmy ) { - if ( !plsc->label_data ) + if ( !custom_exponent_placement ) { height = 3.4; // Extra space for superscript pos = 1.0 + offset; @@ -1888,6 +1890,10 @@ PLFLT default_mm, char_height_mm, height_mm; PLFLT string_length_mm = 0.0, pos_mm = 0.0; + // Assume label data is for placement of exponents if no custom + // label function is provided. + PLBOOL custom_exponent_placement = !plsc->label_func && plsc->label_data; + plgchr( &default_mm, &char_height_mm ); // Save some parameters @@ -2068,9 +2074,7 @@ if ( !llx && !ldx && !lox && xmode ) { - // Assume label data is for placement of exponents if no custom - // label function is provided. - if ( !plsc->label_func && plsc->label_data ) + if ( custom_exponent_placement ) { height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; @@ -2326,7 +2330,7 @@ if ( !lly && !ldy && !loy && ymode ) { snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale ); - if ( !plsc->label_func && plsc->label_data ) + if ( custom_exponent_placement ) { height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; @@ -2343,7 +2347,7 @@ // Left axis exponent. if ( lny ) { - if ( !plsc->label_data ) + if ( !custom_exponent_placement ) { height = 3.2; pos = 1.0 + offset; @@ -2381,7 +2385,7 @@ // Right axis exponent. if ( lmy ) { - if ( !plsc->label_data ) + if ( !custom_exponent_placement ) { height = 3.4; // Extra space for superscript pos = 1.0 + offset; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |