diff mbox

[2/4] xl: wrap long lines where possible

Message ID 1453463454-4114-3-git-send-email-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Jan. 22, 2016, 11:50 a.m. UTC
No functional changes introduced.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/xl_cmdimpl.c | 107 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 73 insertions(+), 34 deletions(-)

Comments

Ian Campbell Jan. 25, 2016, 12:17 p.m. UTC | #1
On Fri, 2016-01-22 at 11:50 +0000, Wei Liu wrote:
> No functional changes introduced.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

(unread)
diff mbox

Patch

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index f380799..ff561c3 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -237,12 +237,14 @@  static int acquire_lock(void)
     fl.l_len = 0;
     fd_lock = open(lockfile, O_WRONLY|O_CREAT, S_IWUSR);
     if (fd_lock < 0) {
-        fprintf(stderr, "cannot open the lockfile %s errno=%d\n", lockfile, errno);
+        fprintf(stderr, "cannot open the lockfile %s errno=%d\n",
+                lockfile, errno);
         return ERROR_FAIL;
     }
     if (fcntl(fd_lock, F_SETFD, FD_CLOEXEC) < 0) {
         close(fd_lock);
-        fprintf(stderr, "cannot set cloexec to lockfile %s errno=%d\n", lockfile, errno);
+        fprintf(stderr, "cannot set cloexec to lockfile %s errno=%d\n",
+                lockfile, errno);
         return ERROR_FAIL;
     }
 get_lock:
@@ -538,12 +540,16 @@  out:
     return ret;
 }
 
-static int parse_action_on_shutdown(const char *buf, libxl_action_on_shutdown *a)
+static int parse_action_on_shutdown(const char *buf,
+                                    libxl_action_on_shutdown *a)
 {
-    int i;
+    int i, size;
     const char *n;
 
-    for (i = 0; i < sizeof(action_on_shutdown_names) / sizeof(action_on_shutdown_names[0]); i++) {
+    size = sizeof(action_on_shutdown_names) /
+        sizeof(action_on_shutdown_names[0]);
+
+    for (i = 0; i < size; i++) {
         n = action_on_shutdown_names[i];
 
         if (!n) continue;
@@ -994,7 +1000,8 @@  static int match_option_size(const char *prefix, size_t len,
 /* Parses network data and adds info into nic
  * Returns 1 if the input token does not match one of the keys
  * or parsed values are not correct. Successful parse returns 0 */
-static int parse_nic_config(libxl_device_nic *nic, XLU_Config **config, char *token)
+static int parse_nic_config(libxl_device_nic *nic, XLU_Config **config,
+                            char *token)
 {
     char *endptr, *oparg;
     int i;
@@ -1040,7 +1047,8 @@  static int parse_nic_config(libxl_device_nic *nic, XLU_Config **config, char *to
     } else if (MATCH_OPTION("rate", token, oparg)) {
         parse_vif_rate(config, oparg, nic);
     } else if (MATCH_OPTION("accel", token, oparg)) {
-        fprintf(stderr, "the accel parameter for vifs is currently not supported\n");
+        fprintf(stderr,
+                "the accel parameter for vifs is currently not supported\n");
     } else {
         fprintf(stderr, "unrecognized argument `%s'\n", token);
         return 1;
@@ -1580,13 +1588,15 @@  static void parse_config_data(const char *config_source,
 
             if (l < LIBXL_TIMER_MODE_DELAY_FOR_MISSED_TICKS ||
                 l > LIBXL_TIMER_MODE_ONE_MISSED_TICK_PENDING) {
-                fprintf(stderr, "ERROR: invalid value %ld for \"timer_mode\"\n", l);
+                fprintf(stderr,
+                        "ERROR: invalid value %ld for \"timer_mode\"\n", l);
                 exit (1);
             }
             b_info->u.hvm.timer_mode = l;
         } else if (!xlu_cfg_get_string(config, "timer_mode", &buf, 0)) {
             if (libxl_timer_mode_from_string(buf, &b_info->u.hvm.timer_mode)) {
-                fprintf(stderr, "ERROR: invalid value \"%s\" for \"timer_mode\"\n",
+                fprintf(stderr,
+                        "ERROR: invalid value \"%s\" for \"timer_mode\"\n",
                         buf);
                 exit (1);
             }
@@ -1605,7 +1615,8 @@  static void parse_config_data(const char *config_source,
             if (!strcmp(buf, "generate")) {
                 e = libxl_ms_vm_genid_generate(ctx, &b_info->u.hvm.ms_vm_genid);
                 if (e) {
-                    fprintf(stderr, "ERROR: failed to generate a VM Generation ID\n");
+                    fprintf(stderr,
+                            "ERROR: failed to generate a VM Generation ID\n");
                     exit(1);
                 }
             } else if (!strcmp(buf, "none")) {
@@ -1621,7 +1632,8 @@  static void parse_config_data(const char *config_source,
         break;
     case LIBXL_DOMAIN_TYPE_PV:
     {
-        xlu_cfg_replace_string (config, "bootloader", &b_info->u.pv.bootloader, 0);
+        xlu_cfg_replace_string (config, "bootloader",
+                                &b_info->u.pv.bootloader, 0);
         switch (xlu_cfg_get_list_as_string_list(config, "bootloader_args",
                                       &b_info->u.pv.bootloader_args, 1))
         {
@@ -1772,7 +1784,8 @@  static void parse_config_data(const char *config_source,
     if (!xlu_cfg_get_list (config, "disk", &vbds, 0, 0)) {
         d_config->num_disks = 0;
         d_config->disks = NULL;
-        while ((buf = xlu_cfg_get_listitem (vbds, d_config->num_disks)) != NULL) {
+        while ((buf = xlu_cfg_get_listitem (vbds, d_config->num_disks))
+               != NULL) {
             libxl_device_disk *disk;
             char *buf2 = strdup(buf);
 
@@ -1788,7 +1801,8 @@  static void parse_config_data(const char *config_source,
     if (!xlu_cfg_get_list(config, "vtpm", &vtpms, 0, 0)) {
         d_config->num_vtpms = 0;
         d_config->vtpms = NULL;
-        while ((buf = xlu_cfg_get_listitem (vtpms, d_config->num_vtpms)) != NULL) {
+        while ((buf = xlu_cfg_get_listitem (vtpms, d_config->num_vtpms))
+               != NULL) {
             libxl_device_vtpm *vtpm;
             char * buf2 = strdup(buf);
             char *p, *p2;
@@ -1889,7 +1903,8 @@  static void parse_config_data(const char *config_source,
                 exit(1);
             case LIBXL_CHANNEL_CONNECTION_SOCKET:
                 if (!path) {
-                    fprintf(stderr, "channel connection 'socket' requires path=..\n");
+                    fprintf(stderr,
+                            "channel connection 'socket' requires path=..\n");
                     exit(1);
                 }
                 chn->u.socket.path = xstrdup(path);
@@ -1910,7 +1925,8 @@  static void parse_config_data(const char *config_source,
     if (!xlu_cfg_get_list (config, "vif", &nics, 0, 0)) {
         d_config->num_nics = 0;
         d_config->nics = NULL;
-        while ((buf = xlu_cfg_get_listitem (nics, d_config->num_nics)) != NULL) {
+        while ((buf = xlu_cfg_get_listitem (nics, d_config->num_nics))
+               != NULL) {
             libxl_device_nic *nic;
             char *buf2 = strdup(buf);
             char *p;
@@ -1943,7 +1959,8 @@  skip_nic:
     d_config->vkbs = NULL;
 
     if (!xlu_cfg_get_list (config, "vfb", &cvfbs, 0, 0)) {
-        while ((buf = xlu_cfg_get_listitem (cvfbs, d_config->num_vfbs)) != NULL) {
+        while ((buf = xlu_cfg_get_listitem (cvfbs, d_config->num_vfbs))
+               != NULL) {
             libxl_device_vfb *vfb;
             libxl_device_vkb *vkb;
 
@@ -2462,7 +2479,8 @@  static domain_restart_type handle_domain_death(uint32_t *r_domid,
         event->u.domain_shutdown.shutdown_reason,
         action_on_shutdown_names[action]);
 
-    if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY || action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART) {
+    if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY ||
+        action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART) {
         char *corefile;
         int rc;
 
@@ -2699,7 +2717,8 @@  static uint32_t create_domain(struct domain_create *dom_info)
             restore_source = restore_file;
             restore_fd = open(restore_file, O_RDONLY);
             if (restore_fd == -1) {
-                fprintf(stderr, "Can't open restore file: %s\n", strerror(errno));
+                fprintf(stderr,
+                        "Can't open restore file: %s\n", strerror(errno));
                 return ERROR_INVAL;
             }
             restore_fd_to_close = restore_fd;
@@ -2776,8 +2795,11 @@  static uint32_t create_domain(struct domain_create *dom_info)
         } else {
             ret = libxl_read_file_contents(ctx, config_file,
                                            &config_data, &config_len);
-            if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
-                               config_file, strerror(errno)); return ERROR_FAIL; }
+            if (ret) {
+                fprintf(stderr, "Failed to read config file: %s: %s\n",
+                        config_file, strerror(errno));
+                return ERROR_FAIL;
+            }
         }
         if (!restoring && extra_config && strlen(extra_config)) {
             if (config_len > INT_MAX - (strlen(extra_config) + 2 + 1)) {
@@ -3286,7 +3308,9 @@  int main_memmax(int argc, char **argv)
 
     rc = set_memory_max(domid, mem);
     if (rc) {
-        fprintf(stderr, "cannot set domid %d static max memory to : %s\n", domid, mem);
+        fprintf(stderr,
+                "cannot set domid %d static max memory to : %s\n",
+                domid, mem);
         return 1;
     }
 
@@ -3460,7 +3484,8 @@  static void pcilist(uint32_t domid)
     for (i = 0; i < num; i++) {
         printf("%02x.%01x %04x:%02x:%02x.%01x\n",
                (pcidevs[i].vdevfn >> 3) & 0x1f, pcidevs[i].vdevfn & 0x7,
-               pcidevs[i].domain, pcidevs[i].bus, pcidevs[i].dev, pcidevs[i].func);
+               pcidevs[i].domain,
+               pcidevs[i].bus, pcidevs[i].dev, pcidevs[i].func);
         libxl_device_pci_dispose(&pcidevs[i]);
     }
     free(pcidevs);
@@ -3492,7 +3517,8 @@  static void pcidetach(uint32_t domid, const char *bdf, int force)
     if (!config) { perror("xlu_cfg_inig"); exit(-1); }
 
     if (xlu_pci_parse_bdf(config, &pcidev, bdf)) {
-        fprintf(stderr, "pci-detach: malformed BDF specification \"%s\"\n", bdf);
+        fprintf(stderr,
+                "pci-detach: malformed BDF specification \"%s\"\n", bdf);
         exit(2);
     }
     if (force)
@@ -3534,7 +3560,8 @@  static void pciattach(uint32_t domid, const char *bdf, const char *vs)
     if (!config) { perror("xlu_cfg_inig"); exit(-1); }
 
     if (xlu_pci_parse_bdf(config, &pcidev, bdf)) {
-        fprintf(stderr, "pci-attach: malformed BDF specification \"%s\"\n", bdf);
+        fprintf(stderr,
+                "pci-attach: malformed BDF specification \"%s\"\n", bdf);
         exit(2);
     }
     libxl_device_pci_add(ctx, domid, &pcidev, 0);
@@ -3574,7 +3601,8 @@  static void pciassignable_list(void)
         return;
     for (i = 0; i < num; i++) {
         printf("%04x:%02x:%02x.%01x\n",
-               pcidevs[i].domain, pcidevs[i].bus, pcidevs[i].dev, pcidevs[i].func);
+               pcidevs[i].domain,
+               pcidevs[i].bus, pcidevs[i].dev, pcidevs[i].func);
         libxl_device_pci_dispose(&pcidevs[i]);
     }
     free(pcidevs);
@@ -3603,7 +3631,9 @@  static void pciassignable_add(const char *bdf, int rebind)
     if (!config) { perror("xlu_cfg_init"); exit(-1); }
 
     if (xlu_pci_parse_bdf(config, &pcidev, bdf)) {
-        fprintf(stderr, "pci-assignable-add: malformed BDF specification \"%s\"\n", bdf);
+        fprintf(stderr,
+                "pci-assignable-add: malformed BDF specification \"%s\"\n",
+                bdf);
         exit(2);
     }
     libxl_device_pci_assignable_add(ctx, &pcidev, rebind);
@@ -3638,7 +3668,9 @@  static void pciassignable_remove(const char *bdf, int rebind)
     if (!config) { perror("xlu_cfg_init"); exit(-1); }
 
     if (xlu_pci_parse_bdf(config, &pcidev, bdf)) {
-        fprintf(stderr, "pci-assignable-remove: malformed BDF specification \"%s\"\n", bdf);
+        fprintf(stderr,
+                "pci-assignable-remove: malformed BDF specification \"%s\"\n",
+                bdf);
         exit(2);
     }
     libxl_device_pci_assignable_remove(ctx, &pcidev, rebind);
@@ -5817,7 +5849,8 @@  static int sched_domain_set(int domid, const libxl_domain_sched_params *scinfo)
     return 0;
 }
 
-static int sched_credit_params_set(int poolid, libxl_sched_credit_params *scinfo)
+static int sched_credit_params_set(int poolid,
+                                   libxl_sched_credit_params *scinfo)
 {
     if (libxl_sched_credit_params_set(ctx, poolid, scinfo)) {
         fprintf(stderr, "libxl_sched_credit_params_set failed.\n");
@@ -5827,7 +5860,8 @@  static int sched_credit_params_set(int poolid, libxl_sched_credit_params *scinfo
     return 0;
 }
 
-static int sched_credit_params_get(int poolid, libxl_sched_credit_params *scinfo)
+static int sched_credit_params_get(int poolid,
+                                   libxl_sched_credit_params *scinfo)
 {
     if (libxl_sched_credit_params_get(ctx, poolid, scinfo)) {
         fprintf(stderr, "libxl_sched_credit_params_get failed.\n");
@@ -6699,8 +6733,9 @@  int main_blocklist(int argc, char **argv)
             if (!libxl_device_disk_getinfo(ctx, domid, &disks[i], &diskinfo)) {
                 /*      Vdev BE   hdl  st   evch rref BE-path*/
                 printf("%-5d %-3d %-6d %-5d %-6d %-8d %-30s\n",
-                       diskinfo.devid, diskinfo.backend_id, diskinfo.frontend_id,
-                       diskinfo.state, diskinfo.evtch, diskinfo.rref, diskinfo.backend);
+                       diskinfo.devid, diskinfo.backend_id,
+                       diskinfo.frontend_id, diskinfo.state,
+                       diskinfo.evtch, diskinfo.rref, diskinfo.backend);
                 libxl_diskinfo_dispose(&diskinfo);
             }
             libxl_device_disk_dispose(&disks[i]);
@@ -6880,9 +6915,11 @@  static char *uptime_to_string(unsigned long uptime, int short_mode)
             xasprintf(&time_string, "%2d:%02d", hour, min);
     else
         if (day > 1)
-            xasprintf(&time_string, "%d days, %2d:%02d:%02d", day, hour, min, sec);
+            xasprintf(&time_string, "%d days, %2d:%02d:%02d",
+                      day, hour, min, sec);
         else if (day == 1)
-            xasprintf(&time_string, "%d day, %2d:%02d:%02d", day, hour, min, sec);
+            xasprintf(&time_string, "%d day, %2d:%02d:%02d",
+                      day, hour, min, sec);
         else
             xasprintf(&time_string, "%2d:%02d:%02d", hour, min, sec);
 
@@ -7922,7 +7959,9 @@  int main_setenforce(int argc, char **argv)
             fprintf(stderr, "Flask XSM disabled\n");
         }
         else
-            fprintf(stderr, "error occured while setting enforcing mode (%i)\n", ret);
+            fprintf(stderr,
+                    "error occured while setting enforcing mode (%i)\n",
+                    ret);
     }
 
     return ret;