[Nagios-devel] [PATCH] Unused variables x and found_macro_x on
Posted: Fri Jun 22, 2012 5:58 pm
hello,
i've removed two unused variables on found_macro_x() function.
Compiler errors:
../common/macros.c: In function =E2=80=98process_macros_r=E2=80=99:
../common/macros.c:133:6: warning: variable =E2=80=98found_macro_x=E2=80=99=
set but not used [-Wunused-but-set-variable]
../common/macros.c:128:6: warning: variable =E2=80=98x=E2=80=99 set but not=
used [-Wunused-but-set-variable]
OK? Comments?
--- common/macros.c=09(revision 1973)
+++ common/macros.c=09(working copy)
@@ -125,12 +125,10 @@
=09char *buf_ptr =3D NULL;
=09char *delim_ptr =3D NULL;
=09int in_macro =3D FALSE;
-=09int x =3D 0;
=09char *selected_macro =3D NULL;
=09char *original_macro =3D NULL;
=09char *cleaned_macro =3D NULL;
=09int clean_macro =3D FALSE;
-=09int found_macro_x =3D FALSE;
=09int result =3D OK;
=09int clean_options =3D 0;
=09int free_macro =3D FALSE;
@@ -171,7 +169,6 @@
=09=09log_debug_info(DEBUGL_MACROS, 2, " Processing part: '%s'\n", temp_b=
uffer);
=20
=09=09selected_macro =3D NULL;
-=09=09found_macro_x =3D FALSE;
=09=09clean_macro =3D FALSE;
=20
=09=09/* we're in plain text... */
@@ -202,19 +199,16 @@
=09=09=09=09=09my_free(selected_macro);
=09=09=09=09}
=20
-=09=09=09/* we already have a macro... */
-=09=09=09if(result =3D=3D OK)
-=09=09=09=09x =3D 0;
=20
=09=09=09/* an escaped $ is done by specifying two $$ next to each other *=
/
-=09=09=09else if(!strcmp(temp_buffer, "")) {
+=09=09=09if(!strcmp(temp_buffer, "") && result !=3D OK) {
=09=09=09=09log_debug_info(DEBUGL_MACROS, 2, " Escaped $. Running output=
(%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
=09=09=09=09*output_buffer =3D (char *)realloc(*output_buffer, strlen(*out=
put_buffer) + 2);
=09=09=09=09strcat(*output_buffer, "$");
=09=09=09=09}
=20
=09=09=09/* a non-macro, just some user-defined string between two $s */
-=09=09=09else {
+=09=09=09else if(result !=3D OK){
=09=09=09=09log_debug_info(DEBUGL_MACROS, 2, " Non-macro. Running output=
(%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
=20
=09=09=09=09/* add the plain text to the end of the already processed buff=
er */
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
i've removed two unused variables on found_macro_x() function.
Compiler errors:
../common/macros.c: In function =E2=80=98process_macros_r=E2=80=99:
../common/macros.c:133:6: warning: variable =E2=80=98found_macro_x=E2=80=99=
set but not used [-Wunused-but-set-variable]
../common/macros.c:128:6: warning: variable =E2=80=98x=E2=80=99 set but not=
used [-Wunused-but-set-variable]
OK? Comments?
--- common/macros.c=09(revision 1973)
+++ common/macros.c=09(working copy)
@@ -125,12 +125,10 @@
=09char *buf_ptr =3D NULL;
=09char *delim_ptr =3D NULL;
=09int in_macro =3D FALSE;
-=09int x =3D 0;
=09char *selected_macro =3D NULL;
=09char *original_macro =3D NULL;
=09char *cleaned_macro =3D NULL;
=09int clean_macro =3D FALSE;
-=09int found_macro_x =3D FALSE;
=09int result =3D OK;
=09int clean_options =3D 0;
=09int free_macro =3D FALSE;
@@ -171,7 +169,6 @@
=09=09log_debug_info(DEBUGL_MACROS, 2, " Processing part: '%s'\n", temp_b=
uffer);
=20
=09=09selected_macro =3D NULL;
-=09=09found_macro_x =3D FALSE;
=09=09clean_macro =3D FALSE;
=20
=09=09/* we're in plain text... */
@@ -202,19 +199,16 @@
=09=09=09=09=09my_free(selected_macro);
=09=09=09=09}
=20
-=09=09=09/* we already have a macro... */
-=09=09=09if(result =3D=3D OK)
-=09=09=09=09x =3D 0;
=20
=09=09=09/* an escaped $ is done by specifying two $$ next to each other *=
/
-=09=09=09else if(!strcmp(temp_buffer, "")) {
+=09=09=09if(!strcmp(temp_buffer, "") && result !=3D OK) {
=09=09=09=09log_debug_info(DEBUGL_MACROS, 2, " Escaped $. Running output=
(%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
=09=09=09=09*output_buffer =3D (char *)realloc(*output_buffer, strlen(*out=
put_buffer) + 2);
=09=09=09=09strcat(*output_buffer, "$");
=09=09=09=09}
=20
=09=09=09/* a non-macro, just some user-defined string between two $s */
-=09=09=09else {
+=09=09=09else if(result !=3D OK){
=09=09=09=09log_debug_info(DEBUGL_MACROS, 2, " Non-macro. Running output=
(%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
=20
=09=09=09=09/* add the plain text to the end of the already processed buff=
er */
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]