remove superfluous strdup(3) from parse.y files; Patch by Martin Vahlensieck
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
diff --git a/gotweb/parse.y b/gotweb/parse.y
index 2d9864e..91c2400 100644
--- a/gotweb/parse.y
+++ b/gotweb/parse.y
@@ -118,71 +118,29 @@ boolean : STRING {
}
;
main : GOT_REPOS_PATH STRING {
- gw_conf->got_repos_path = strdup($2);
- if (gw_conf->got_repos_path == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ gw_conf->got_repos_path = $2;
}
| GOT_WWW_PATH STRING {
- gw_conf->got_www_path = strdup($2);
- if (gw_conf->got_www_path == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ gw_conf->got_www_path = $2;
}
| GOT_MAX_REPOS NUMBER {
if ($2 > 0)
gw_conf->got_max_repos = $2;
}
| GOT_SITE_NAME STRING {
- gw_conf->got_site_name = strdup($2);
- if (gw_conf->got_site_name == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ gw_conf->got_site_name = $2;
}
| GOT_SITE_OWNER STRING {
- gw_conf->got_site_owner = strdup($2);
- if (gw_conf->got_site_owner == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ gw_conf->got_site_owner = $2;
}
| GOT_SITE_LINK STRING {
- gw_conf->got_site_link = strdup($2);
- if (gw_conf->got_site_link == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ gw_conf->got_site_link = $2;
}
| GOT_LOGO STRING {
- gw_conf->got_logo = strdup($2);
- if (gw_conf->got_logo== NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ gw_conf->got_logo = $2;
}
| GOT_LOGO_URL STRING {
- gw_conf->got_logo_url = strdup($2);
- if (gw_conf->got_logo_url== NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ gw_conf->got_logo_url = $2;
}
| GOT_SHOW_SITE_OWNER boolean {
gw_conf->got_show_site_owner = $2;
@@ -232,9 +190,8 @@ yyerror(const char *fmt, ...)
gerror = got_error_from_errno("asprintf");
return(0);
}
- gerror = got_error_msg(GOT_ERR_PARSE_CONFIG, strdup(err));
+ gerror = got_error_msg(GOT_ERR_PARSE_CONFIG, err);
free(msg);
- free(err);
return(0);
}
diff --git a/libexec/got-read-gotconfig/parse.y b/libexec/got-read-gotconfig/parse.y
index f1fe635..13c0d95 100644
--- a/libexec/got-read-gotconfig/parse.y
+++ b/libexec/got-read-gotconfig/parse.y
@@ -192,31 +192,13 @@ remoteopts2 : remoteopts2 remoteopts1 nl
| remoteopts1 optnl
;
remoteopts1 : REPOSITORY STRING {
- remote->repository = strdup($2);
- if (remote->repository == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->repository = $2;
}
| SERVER STRING {
- remote->server = strdup($2);
- if (remote->server == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->server = $2;
}
| PROTOCOL STRING {
- remote->protocol = strdup($2);
- if (remote->protocol == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->protocol = $2;
}
| MIRROR_REFERENCES boolean {
remote->mirror_references = $2;
@@ -267,31 +249,13 @@ fetchopts2 : fetchopts2 fetchopts1 nl
| fetchopts1 optnl
;
fetchopts1 : REPOSITORY STRING {
- remote->fetch_config->repository = strdup($2);
- if (remote->fetch_config->repository == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->fetch_config->repository = $2;
}
| SERVER STRING {
- remote->fetch_config->server = strdup($2);
- if (remote->fetch_config->server == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->fetch_config->server = $2;
}
| PROTOCOL STRING {
- remote->fetch_config->protocol = strdup($2);
- if (remote->fetch_config->protocol == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->fetch_config->protocol = $2;
}
| PORT portplain {
remote->fetch_config->port = $2;
@@ -307,31 +271,13 @@ sendopts2 : sendopts2 sendopts1 nl
| sendopts1 optnl
;
sendopts1 : REPOSITORY STRING {
- remote->send_config->repository = strdup($2);
- if (remote->send_config->repository == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->send_config->repository = $2;
}
| SERVER STRING {
- remote->send_config->server = strdup($2);
- if (remote->send_config->server == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->send_config->server = $2;
}
| PROTOCOL STRING {
- remote->send_config->protocol = strdup($2);
- if (remote->send_config->protocol == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->send_config->protocol = $2;
}
| PORT portplain {
remote->send_config->port = $2;
@@ -349,26 +295,14 @@ remote : REMOTE STRING {
yyerror("%s", error->msg);
YYERROR;
}
- remote->name = strdup($2);
- if (remote->name == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ remote->name = $2;
} '{' optnl remoteopts2 '}' {
TAILQ_INSERT_TAIL(&gotconfig.remotes, remote, entry);
gotconfig.nremotes++;
}
;
author : AUTHOR STRING {
- gotconfig.author = strdup($2);
- if (gotconfig.author == NULL) {
- free($2);
- yyerror("strdup");
- YYERROR;
- }
- free($2);
+ gotconfig.author = $2;
}
;
optnl : '\n' optnl
@@ -404,9 +338,8 @@ yyerror(const char *fmt, ...)
gerror = got_error_from_errno("asprintf");
return(0);
}
- gerror = got_error_msg(GOT_ERR_PARSE_CONFIG, strdup(err));
+ gerror = got_error_msg(GOT_ERR_PARSE_CONFIG, err);
free(msg);
- free(err);
return(0);
}
int