gluster: Fix the recursive goto outs in the source code.
Added a script check_goto.pl, that when run from the source code root, will scan all .c files to match the following pattern: label: if (condition) goto label; On finding such a pattern the script will print the file name and the line number. There are certain cases where the above recursive pattern is intended. Hence adding those labels to ignore-labels. Thanks Vijaikumar Mallikarjuna for the perl script. Also fixed all such existing errors Change-Id: I1b821d0a8c296f16e40faff20bd029bdc880c2e9 BUG: 1119256 Signed-off-by: Vijaikumar Mallikarjuna <vmallika@redhat.com> Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/8307 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
This commit is contained in:
parent
5b8de971a4
commit
f6ddb4675c
45
extras/check_goto.pl
Executable file
45
extras/check_goto.pl
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my @ignore_labels = qw (TODO retry fetch_data again try_again sp_state_read_proghdr redo disabled_loop fd_alloc_try_again);
|
||||
my @ignore_files = qw (y.tab.c lex.c);
|
||||
my @c_files;
|
||||
my $line;
|
||||
my @labels;
|
||||
my $in_comments;
|
||||
|
||||
{
|
||||
local $" = "|";
|
||||
my $cmd = "find . -type f -name '*.c' | grep -vE '(@ignore_files)'";
|
||||
@c_files = `$cmd`;
|
||||
}
|
||||
|
||||
foreach my $file (@c_files) {
|
||||
chomp ($file);
|
||||
open FD, $file or die ("Failed to read file $file: $!");
|
||||
@labels = ();
|
||||
$in_comments = 0;
|
||||
while ($line = <FD>) {
|
||||
chomp ($line);
|
||||
|
||||
next if $line =~ /^\s*(#|\/\/)/;
|
||||
$in_comments = 1 if ($line =~ /\/\*/);
|
||||
$in_comments = 0 if ($line =~ /\*\//);
|
||||
|
||||
next if $in_comments;
|
||||
if ($line =~ /^\s*(([a-zA-Z]|_)\w*)\s*:/) {
|
||||
push (@labels, $1) unless grep (/$1/, @ignore_labels);
|
||||
}
|
||||
@labels = () if $line =~ /^}/;
|
||||
|
||||
next unless @labels;
|
||||
if ($line =~ /^\s*goto\s*(\w+)/) {
|
||||
print "$file:$.: $line\n" if grep /^$1$/, @labels;
|
||||
}
|
||||
}
|
||||
|
||||
close FD;
|
||||
}
|
||||
|
@ -518,10 +518,8 @@ out:
|
||||
if (newfd)
|
||||
close (newfd);
|
||||
ret = unlink (filename);
|
||||
if (ret < 0) {
|
||||
if (ret < 0)
|
||||
fprintf (stderr, "unlink failed : %s\n", strerror (errno));
|
||||
goto out;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -755,16 +755,14 @@ out:
|
||||
if (ret) {
|
||||
gf_log (this->name, GF_LOG_ERROR, "Failed to "
|
||||
"compute cksum for quota conf file");
|
||||
goto out;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = glusterd_store_save_quota_version_and_cksum
|
||||
(volinfo);
|
||||
if (ret) {
|
||||
if (ret)
|
||||
gf_log (this->name, GF_LOG_ERROR, "Failed to "
|
||||
"store quota version and cksum");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1186,7 +1186,8 @@ out:
|
||||
ret = glusterd_validate_and_set_gfid (op_ctx, req_dict,
|
||||
op_errstr);
|
||||
if (ret)
|
||||
goto out;
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Failed to validate and set gfid");
|
||||
}
|
||||
|
||||
if (rsp_dict)
|
||||
|
@ -3923,14 +3923,19 @@ glusterd_import_quota_conf (dict_t *peer_data, int vol_idx,
|
||||
out:
|
||||
if (!ret) {
|
||||
ret = glusterd_compute_cksum (new_volinfo, _gf_true);
|
||||
if (ret)
|
||||
goto out;
|
||||
if (ret) {
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Failed to compute checksum");
|
||||
goto clear_quota_conf;
|
||||
}
|
||||
|
||||
ret = glusterd_store_save_quota_version_and_cksum (new_volinfo);
|
||||
if (ret)
|
||||
goto out;
|
||||
gf_log (this->name, GF_LOG_ERROR,
|
||||
"Failed to save quota version and checksum");
|
||||
}
|
||||
|
||||
clear_quota_conf:
|
||||
if (ret && (fd > 0)) {
|
||||
gf_store_unlink_tmppath (new_volinfo->quota_conf_shandle);
|
||||
(void) gf_store_handle_destroy
|
||||
@ -6724,6 +6729,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
|
||||
char buf[1024] = "faulty";
|
||||
int uuid_len = 0;
|
||||
int ret = 0;
|
||||
int op_ret = 0;
|
||||
int ret_status = 0;
|
||||
char uuid_str[64] = {0};
|
||||
glusterd_volinfo_t *volinfo = NULL;
|
||||
@ -6849,15 +6855,14 @@ out:
|
||||
GF_FREE (statefile);
|
||||
|
||||
if (is_template_in_use) {
|
||||
ret = glusterd_create_status_file (volinfo->volname, slave,
|
||||
slave_host, slave_vol,
|
||||
"Config Corrupted");
|
||||
if (ret) {
|
||||
op_ret = glusterd_create_status_file (volinfo->volname, slave,
|
||||
slave_host, slave_vol,
|
||||
"Config Corrupted");
|
||||
if (op_ret) {
|
||||
gf_log ("", GF_LOG_ERROR,
|
||||
"Unable to create status file"
|
||||
". Error : %s", strerror (errno));
|
||||
ret = -1;
|
||||
goto out;
|
||||
ret = op_ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user