Avoid pointer syntax when possible.
They are different, the array syntax generates smaller, faster code.
See for example:
https://eklitzke.org/declaring-c-string-constants-the-right-way
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
{
int result, blind_retry = 0;
struct oc_text_buf *request_body = buf_alloc();
- const char *request_body_type = "application/x-www-form-urlencoded";
char *xml_buf = NULL, *orig_path;
/* Ask the user to fill in the auth form; repeat as necessary */
orig_path = vpninfo->urlpath;
vpninfo->urlpath = strdup(portal ? "global-protect/getconfig.esp" : "ssl-vpn/login.esp");
- result = do_https_request(vpninfo, "POST", request_body_type, request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
+ result = do_https_request(vpninfo, "POST", "application/x-www-form-urlencoded", request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
free(vpninfo->urlpath);
vpninfo->urlpath = orig_path;
char *orig_path;
int result;
struct oc_text_buf *request_body = buf_alloc();
- const char *request_body_type = "application/x-www-form-urlencoded";
- const char *method = "POST";
char *xml_buf = NULL;
/* In order to logout successfully, the client must send not only
orig_path = vpninfo->urlpath;
vpninfo->urlpath = strdup("ssl-vpn/logout.esp");
openconnect_close_https(vpninfo, 0);
- result = do_https_request(vpninfo, method, request_body_type, request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
+ result = do_https_request(vpninfo, "POST", "application/x-www-form-urlencoded", request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
free(vpninfo->urlpath);
vpninfo->urlpath = orig_path;
struct oc_text_buf *request_body = buf_alloc();
const char *old_addr = vpninfo->ip_info.addr;
const char *old_addr6 = vpninfo->ip_info.addr6;
- const char *request_body_type = "application/x-www-form-urlencoded";
- const char *method = "POST";
char *xml_buf = NULL;
orig_path = vpninfo->urlpath;
vpninfo->urlpath = strdup("ssl-vpn/getconfig.esp");
- result = do_https_request(vpninfo, method, request_body_type, request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
+ result = do_https_request(vpninfo, "POST", "application/x-www-form-urlencoded", request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
free(vpninfo->urlpath);
vpninfo->urlpath = orig_path;
int result;
struct oc_text_buf *request_body = buf_alloc();
- const char *request_body_type = "application/x-www-form-urlencoded";
- const char *method = "POST";
char *xml_buf=NULL, *orig_path;
/* cookie gives us these fields: authcookie, portal, user, domain, computer, and (maybe the unnecessary) preferred-ip/ipv6 */
orig_path = vpninfo->urlpath;
vpninfo->urlpath = strdup(report ? "ssl-vpn/hipreport.esp" : "ssl-vpn/hipreportcheck.esp");
- result = do_https_request(vpninfo, method, request_body_type, request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
+ result = do_https_request(vpninfo, "POST", "application/x-www-form-urlencoded", request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
free(vpninfo->urlpath);
vpninfo->urlpath = orig_path;
return cancellable_recv(vpninfo, vpninfo->proxy_fd, buf, len);
}
-static const char *socks_errors[] = {
+static const char * const socks_errors[] = {
N_("request granted"),
N_("general failure"),
N_("connection not allowed by ruleset"),
int openconnect_set_reported_os(struct openconnect_info *vpninfo,
const char *os)
{
- const char *allowed[] = {"linux", "linux-64", "win", "mac-intel", "android", "apple-ios"};
+ static const char * const allowed[] = {"linux", "linux-64", "win", "mac-intel", "android", "apple-ios"};
if (!os) {
#if defined(__APPLE__)
return openconnect_setup_tun_fd(vpninfo, tun_fd);
}
-static const char *compr_name_map[] = {
+static const char * const compr_name_map[] = {
[COMPR_DEFLATE] = "Deflate",
[COMPR_LZS] = "LZS",
[COMPR_LZ4] = "LZ4",
static void print_build_opts(void)
{
- const char *comma = ", ", *sep = comma + 1;
+ const char comma[] = ", ", *sep = comma + 1;
printf(_("Using %s. Features present:"), openconnect_get_tls_library_version());
static void print_supported_protocols(void)
{
- const char *comma = ", ", *sep = comma + 1;
+ const char comma[] = ", ", *sep = comma + 1;
struct oc_vpn_proto *protos, *p;
int n;
void openconnect_set_juniper(struct openconnect_info *vpninfo);
/* version.c */
-extern const char *openconnect_version_str;
+extern const char openconnect_version_str[];
static inline int certinfo_is_primary(struct cert_info *certinfo)
}
}
-static const char *ppps_names[] = {
+static const char * const ppps_names[] = {
"DEAD",
"ESTABLISH",
"OPENED",
"TERMINATE"
};
-static const char *encap_names[PPP_ENCAP_MAX+1] = {
+static const char * const encap_names[PPP_ENCAP_MAX+1] = {
NULL,
"RFC1661",
"RFC1662 HDLC",
"FORTINET",
};
-static const char *lcp_names[] = {
+static const char * const lcp_names[] = {
NULL,
"Configure-Request",
"Configure-Ack",
v="$v"-unknown
fi
-echo "const char *openconnect_version_str = \"$v\";" > $1
+echo "const char openconnect_version_str[] = \"$v\";" > $1
echo "New version: $v"