Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
close filehandle only if we opened one
  • Loading branch information
DanyT committed Jul 2, 2024
1 parent 6d3bd66 commit 8f759fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kubernetes/config/kube_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ int load_kube_config_common(char **pBasePath, sslConfig_t ** pSslConfig, list_t

rc = kubeyaml_load_kubeconfig(kubeconfig);
if (0 != rc) {
fprintf(stderr, "%s: Cannot load the kubeconfig %s\n", fname, kubeconfig->fileName);
fprintf(stderr, "%s: Cannot load the kubeconfig %s\n", fname, kubeconfig->fileName?kubeconfig->fileName:kubeconfig->buffer);
rc = -1;
goto end;
}
Expand Down
11 changes: 8 additions & 3 deletions kubernetes/config/kube_config_yaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,11 @@ int kubeyaml_load_kubeconfig(kubeconfig_t * kubeconfig)
fprintf(stderr, "%s: Cannot open the file %s.[%s]\n", fname, kubeconfig->fileName, strerror(errno));
return -1;
}
}
else if (kubeconfig->buffer) {
// Nothing to do here for now.
}
} else {
else {
fprintf(stderr, "%s: The kubeconf file name needs be set by kubeconfig->fileName .\n", fname);
return -1;
}
Expand Down Expand Up @@ -477,12 +478,16 @@ int kubeyaml_load_kubeconfig(kubeconfig_t * kubeconfig)

/* Cleanup */
yaml_parser_delete(&parser);
fclose(input);
if (input) {
fclose(input);
}
return 0;

error:
yaml_parser_delete(&parser);
fclose(input);
if (input) {
fclose(input);
}
return -1;
}

Expand Down

0 comments on commit 8f759fc

Please sign in to comment.