Skip to content

Commit

Permalink
Merge pull request #129 from tomprince/support-fexceptions
Browse files Browse the repository at this point in the history
Move definition to initilization for cleanup decorated variables.
  • Loading branch information
bcopeland committed Nov 10, 2015
2 parents 882ddc1 + 3f601c8 commit f2acef6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
9 changes: 3 additions & 6 deletions agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ static int agent_socket_get_cred(int fd, struct ucred *cred)

static void agent_run(unsigned const char key[KDF_HASH_LEN])
{
_cleanup_free_ char *path;
char *agent_timeout_str;
unsigned int agent_timeout;
struct sockaddr_un sa, listensa;
Expand All @@ -153,7 +152,7 @@ static void agent_run(unsigned const char key[KDF_HASH_LEN])
if (agent_timeout)
alarm(agent_timeout);

path = agent_socket_path();
_cleanup_free_ char *path = agent_socket_path();
if (strlen(path) >= sizeof(sa.sun_path))
die("Path too large for agent control socket.");

Expand Down Expand Up @@ -200,12 +199,11 @@ static void agent_run(unsigned const char key[KDF_HASH_LEN])

void agent_kill(void)
{
_cleanup_free_ char *path;
struct sockaddr_un sa;
struct ucred cred;
int fd;

path = agent_socket_path();
_cleanup_free_ char *path = agent_socket_path();
if (strlen(path) >= sizeof(sa.sun_path))
die("Path too large for agent control socket.");

Expand Down Expand Up @@ -235,12 +233,11 @@ void agent_kill(void)

static bool agent_ask(unsigned char key[KDF_HASH_LEN])
{
_cleanup_free_ char *path;
struct sockaddr_un sa;
int fd;
bool ret = false;

path = agent_socket_path();
_cleanup_free_ char *path = agent_socket_path();
if (strlen(path) >= sizeof(sa.sun_path))
die("Path too large for agent control socket.");

Expand Down
3 changes: 1 addition & 2 deletions blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,11 @@ size_t blob_write(const struct blob *blob, const unsigned char key[KDF_HASH_LEN]
{
struct buffer buffer;
struct share *last_share = NULL;
_cleanup_free_ char *version;
struct account *account;

memset(&buffer, 0, sizeof(buffer));

version = xultostr(blob->version);
_cleanup_free_ char *version = xultostr(blob->version);
buffer_append(&buffer, "LPAV", 4);
write_plain_string(&buffer, version);
buffer_append(&buffer, "LOCL", 4);
Expand Down
16 changes: 6 additions & 10 deletions cmd-ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ static void print_node(struct node *head, int level)
printf(" ");
if (node->account) {
if (long_listing) {
_cleanup_free_ char *timestr;
if (show_mtime)
timestr = format_timestamp(node->account->last_modified_gmt, true);
else
timestr = format_timestamp(node->account->last_touch, false);
_cleanup_free_ char *timestr = show_mtime ?
format_timestamp(node->account->last_modified_gmt, true) :
format_timestamp(node->account->last_touch, false);
terminal_printf(TERMINAL_FG_CYAN "%s ", timestr);
}
terminal_printf(TERMINAL_FG_GREEN TERMINAL_BOLD "%s" TERMINAL_NO_BOLD " [id: %s]" TERMINAL_RESET "\n", node->name, node->account->id);
Expand Down Expand Up @@ -246,11 +244,9 @@ int cmd_ls(int argc, char **argv)
insert_node(root, fullname, account);
else {
if (long_listing) {
_cleanup_free_ char *timestr;
if (show_mtime)
timestr = format_timestamp(account->last_modified_gmt, true);
else
timestr = format_timestamp(account->last_touch, false);
_cleanup_free_ char *timestr = show_mtime ?
format_timestamp(account->last_modified_gmt, true) :
format_timestamp(account->last_touch, false);
printf("%s ", timestr);
}
printf("%s [id: %s]\n", fullname, account->id);
Expand Down
3 changes: 1 addition & 2 deletions endpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ void lastpass_logout(const struct session *session)
struct blob *lastpass_get_blob(const struct session *session, const unsigned char key[KDF_HASH_LEN])
{
size_t len;
_cleanup_free_ char *blob;

blob = http_post_lastpass("getaccts.php", session->sessionid, &len, "mobile", "1", "requestsrc", "cli", "hasplugin", LASTPASS_CLI_VERSION, NULL);
_cleanup_free_ char *blob = http_post_lastpass("getaccts.php", session->sessionid, &len, "mobile", "1", "requestsrc", "cli", "hasplugin", LASTPASS_CLI_VERSION, NULL);
if (!blob || !len)
return NULL;
config_write_encrypted_buffer("blob", blob, len, key);
Expand Down
3 changes: 1 addition & 2 deletions lpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ static void expand_aliases(int *argc, char ***argv)
int argv_alloced;
int new_argc = 0;
_cleanup_free_ char *config_name;
_cleanup_free_ char *alias_val;

xasprintf(&config_name, "alias.%s", alias);

alias_val = config_read_string(config_name);
_cleanup_free_ char *alias_val = config_read_string(config_name);
if (!alias_val)
return;

Expand Down

0 comments on commit f2acef6

Please sign in to comment.