virsh: change vshCommandOptString return type and fix const-correctness

This function should return pointer to const, because we don't want
to change command option value. Therefore we can ensure const-correctness.

--- tools/virsh.c
+++ tools/virsh.c
@@ -255,8 +255,8 @@
 static int vshCommandOptInt(const vshCmd *cmd, const char *name, int *found);
 static unsigned long vshCommandOptUL(const vshCmd *cmd, const char *name,
                                      int *found);
-static char *vshCommandOptString(const vshCmd *cmd, const char *name,
-                                 int *found);
+static const char *vshCommandOptString(const vshCmd *cmd, const char *name,
+                                       int *found);
 static long long vshCommandOptLongLong(const vshCmd *cmd, const char *name,
                                        int *found);
 static int vshCommandOptBool(const vshCmd *cmd, const char *name);
@@ -268,14 +268,14 @@
 #define VSH_BYMAC    (1 << 4)

 static virDomainPtr vshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd,
-                                          char **name, int flag);
+                                          const char **name, int flag);

 /* default is lookup by Id, Name and UUID */
 #define vshCommandOptDomain(_ctl, _cmd, _name)                      \
     vshCommandOptDomainBy(_ctl, _cmd, _name, VSH_BYID|VSH_BYUUID|VSH_BYNAME)

 static virNetworkPtr vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
-                                            char **name, int flag);
+                                            const char **name, int flag);

 /* default is lookup by Name and UUID */
 #define vshCommandOptNetwork(_ctl, _cmd, _name)                    \
@@ -283,7 +283,7 @@
                            VSH_BYUUID|VSH_BYNAME)

 static virNWFilterPtr vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
-                                                  char **name, int flag);
+                                                  const char **name, int flag);

 /* default is lookup by Name and UUID */
 #define vshCommandOptNWFilter(_ctl, _cmd, _name)                    \
@@ -291,7 +291,7 @@
                             VSH_BYUUID|VSH_BYNAME)

 static virInterfacePtr vshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
-                                                char **name, int flag);
+                                                const char **name, int flag);

 /* default is lookup by Name and MAC */
 #define vshCommandOptInterface(_ctl, _cmd, _name)                    \
@@ -299,7 +299,7 @@
                            VSH_BYMAC|VSH_BYNAME)

 static virStoragePoolPtr vshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd,
-                            const char *optname, char **name, int flag);
+                            const char *optname, const char **name, int flag);

 /* default is lookup by Name and UUID */
 #define vshCommandOptPool(_ctl, _cmd, _optname, _name)           \
@@ -309,7 +309,7 @@
 static virStorageVolPtr vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
                                            const char *optname,
                                            const char *pooloptname,
-                                           char **name, int flag);
+                                           const char **name, int flag);

 /* default is lookup by Name and UUID */
 #define vshCommandOptVol(_ctl, _cmd, _optname, _pooloptname, _name)   \
@@ -317,7 +317,7 @@
                            VSH_BYUUID|VSH_BYNAME)

 static virSecretPtr vshCommandOptSecret(vshControl *ctl, const vshCmd *cmd,
-                                        char **name);
+                                        const char **name);

 static void vshPrintExtra(vshControl *ctl, const char *format, ...)
     ATTRIBUTE_FMT_PRINTF(2, 3);
@@ -643,7 +643,7 @@
 cmdAutostart(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name;
+    const char *name;
     int autostart;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -692,7 +692,7 @@
 cmdConnect(vshControl *ctl, const vshCmd *cmd)
 {
     int ro = vshCommandOptBool(cmd, "readonly");
-    char *name;
+    const char *name;

     if (ctl->conn) {
         int ret;
@@ -964,7 +964,7 @@
 cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name, *device;
+    const char *name, *device;
     struct _virDomainBlockStats stats;

     if (!vshConnectionUsability (ctl, ctl->conn))
@@ -1021,7 +1021,7 @@
 cmdDomIfstat (vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name, *device;
+    const char *name, *device;
     struct _virDomainInterfaceStats stats;

     if (!vshConnectionUsability (ctl, ctl->conn))
@@ -1087,7 +1087,7 @@
 cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name;
+    const char *name;
     struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR];
     unsigned int nr_stats, i;

@@ -1188,7 +1188,7 @@
 cmdSuspend(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name;
+    const char *name;
     int ret = TRUE;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -1230,7 +1230,7 @@
 cmdCreate(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -1288,7 +1288,7 @@
 cmdDefine(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -1336,7 +1336,7 @@
 {
     virDomainPtr dom;
     int ret = TRUE;
-    char *name;
+    const char *name;
     int found;
     int id;

@@ -1454,8 +1454,8 @@
 cmdSave(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name;
-    char *to;
+    const char *name;
+    const char *to;
     int ret = TRUE;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -1499,7 +1499,7 @@
 cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name;
+    const char *name;
     int ret = TRUE;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -1537,7 +1537,7 @@
 cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name;
+    const char *name;
     int ret = FALSE;
     int hassave;

@@ -1595,7 +1595,7 @@
                    virSchedParameterPtr param)
 {
     int found;
-    char *data;
+    const char *data;

     /* Legacy 'weight' parameter */
     if (STREQ(param->field, "weight") &&
@@ -1746,7 +1746,7 @@
             /* See if we've tried to --set var=val.  If so, the fact that
                we reach this point (with update == 0) means that "var" did
                not match any of the settable parameters.  Report the error.  */
-            char *var_value_pair = vshCommandOptString(cmd, "set", NULL);
+            const char *var_value_pair = vshCommandOptString(cmd, "set", NULL);
             if (var_value_pair) {
                 vshError(ctl, _("invalid scheduler option: %s"),
                          var_value_pair);
@@ -1804,7 +1804,7 @@
 static int
 cmdRestore(vshControl *ctl, const vshCmd *cmd)
 {
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;

@@ -1845,8 +1845,8 @@
 cmdDump(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *name;
-    char *to;
+    const char *name;
+    const char *to;
     int ret = TRUE;
     int flags = 0;

@@ -1894,7 +1894,7 @@
 {
     virDomainPtr dom;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -1932,7 +1932,7 @@
 {
     virDomainPtr dom;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -1970,7 +1970,7 @@
 {
     virDomainPtr dom;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -2008,7 +2008,7 @@
 {
     virDomainPtr dom;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -2412,7 +2412,7 @@
 static int
 cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
 {
-    char *type;
+    const char *type;
     int vcpus;

     type = vshCommandOptString(cmd, "type", NULL);
@@ -2712,7 +2712,7 @@
     virDomainPtr dom;
     virNodeInfo nodeinfo;
     int vcpu;
-    char *cpulist;
+    const char *cpulist;
     int ret = TRUE;
     int vcpufound = 0;
     unsigned char *cpumap;
@@ -3315,8 +3315,8 @@
 cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
 {
     int ret = TRUE;
-    char *format;
-    char *configFile;
+    const char *format;
+    const char *configFile;
     char *configData;
     char *xmlData;
     int flags = 0;
@@ -3360,8 +3360,8 @@
 cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
 {
     int ret = TRUE;
-    char *format;
-    char *xmlFile;
+    const char *format;
+    const char *xmlFile;
     char *configData;
     char *xmlData;
     int flags = 0;
@@ -3843,7 +3843,7 @@
 cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
 {
     virNetworkPtr network;
-    char *name;
+    const char *name;
     int autostart;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -3890,7 +3890,7 @@
 cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
 {
     virNetworkPtr network;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -3938,7 +3938,7 @@
 cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
 {
     virNetworkPtr network;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -3987,7 +3987,7 @@
 {
     virNetworkPtr network;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -4418,7 +4418,7 @@
 {
     virNetworkPtr network;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -4711,7 +4711,7 @@
 cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
 {
     virInterfacePtr iface;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -4759,7 +4759,7 @@
 {
     virInterfacePtr iface;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -4797,7 +4797,7 @@
 {
     virInterfacePtr iface;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -4835,7 +4835,7 @@
 {
     virInterfacePtr iface;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -4873,7 +4873,7 @@
 cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
 {
     virNWFilterPtr nwfilter;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -4922,7 +4922,7 @@
 {
     virNWFilterPtr nwfilter;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -5166,7 +5166,7 @@
 cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
 {
     virStoragePoolPtr pool;
-    char *name;
+    const char *name;
     int autostart;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -5214,7 +5214,7 @@
 cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
 {
     virStoragePoolPtr pool;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -5266,7 +5266,7 @@
 cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
 {
     virNodeDevicePtr dev = NULL;
-    char *from;
+    const char *from;
     int found = 0;
     int ret = TRUE;
     char *buffer;
@@ -5320,7 +5320,7 @@
     virNodeDevicePtr dev = NULL;
     int ret = TRUE;
     int found = 0;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn)) {
         return FALSE;
@@ -5361,10 +5361,10 @@
     {NULL, 0, 0, NULL}
 };

-static int buildPoolXML(const vshCmd *cmd, char **retname, char **xml) {
+static int buildPoolXML(const vshCmd *cmd, const char **retname, char **xml) {

     int found;
-    char *name, *type, *srcHost, *srcPath, *srcDev, *srcName, *srcFormat, *target;
+    const char *name, *type, *srcHost, *srcPath, *srcDev, *srcName, *srcFormat, *target;
     virBuffer buf = VIR_BUFFER_INITIALIZER;

     name = vshCommandOptString(cmd, "name", &found);
@@ -5433,7 +5433,8 @@
 cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
 {
     virStoragePoolPtr pool;
-    char *xml, *name;
+    const char *name;
+    char *xml;
     int printXML = vshCommandOptBool(cmd, "print-xml");

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -5479,7 +5480,7 @@
 cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
 {
     virStoragePoolPtr pool;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -5522,7 +5523,8 @@
 cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
 {
     virStoragePoolPtr pool;
-    char *xml, *name;
+    const char *name;
+    char *xml;
     int printXML = vshCommandOptBool(cmd, "print-xml");

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -5569,7 +5571,7 @@
 {
     virStoragePoolPtr pool;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -5609,7 +5611,7 @@
 {
     virStoragePoolPtr pool;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -5648,7 +5650,7 @@
 {
     virStoragePoolPtr pool;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -5687,7 +5689,7 @@
 {
     virStoragePoolPtr pool;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -6176,10 +6178,10 @@
 static int
 cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
 {
-    char *type, *host;
+    const char *type, *host;
     char *srcSpec = NULL;
     char *srcList;
-    char *initiator;
+    const char *initiator;
     int found;

     type = vshCommandOptString(cmd, "type", &found);
@@ -6196,7 +6198,7 @@
         return FALSE;

     if (host) {
-        char *port = vshCommandOptString(cmd, "port", &found);
+        const char *port = vshCommandOptString(cmd, "port", &found);
         if (!found)
             port = NULL;
         virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -6251,8 +6253,8 @@
 static int
 cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
 {
-    char *type, *srcSpecFile, *srcList;
-    char *srcSpec = NULL;
+    const char *type, *srcSpecFile;
+    char *srcSpec = NULL, *srcList;
     int found;

     type = vshCommandOptString(cmd, "type", &found);
@@ -6503,8 +6505,8 @@
     virStorageVolPtr vol;
     int found;
     char *xml;
-    char *name, *capacityStr, *allocationStr, *format;
-    char *snapshotStrVol, *snapshotStrFormat;
+    const char *name, *capacityStr, *allocationStr, *format;
+    const char *snapshotStrVol, *snapshotStrFormat;
     unsigned long long capacity, allocation = 0;
     virBuffer buf = VIR_BUFFER_INITIALIZER;

@@ -6646,7 +6648,7 @@
 {
     virStoragePoolPtr pool;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -6723,7 +6725,7 @@
 {
     virStoragePoolPtr pool;
     virStorageVolPtr vol;
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -6784,7 +6786,7 @@
 {
     virStoragePoolPtr pool = NULL;
     virStorageVolPtr newvol = NULL, inputvol = NULL;
-    char *from;
+    const char *from;
     int found;
     int ret = FALSE;
     char *buffer = NULL;
@@ -6831,7 +6833,7 @@
 }

 static xmlChar *
-makeCloneXML(char *origxml, char *newname) {
+makeCloneXML(const char *origxml, const char *newname) {

     xmlDocPtr doc = NULL;
     xmlXPathContextPtr ctxt = NULL;
@@ -6883,7 +6885,8 @@
 {
     virStoragePoolPtr origpool = NULL;
     virStorageVolPtr origvol = NULL, newvol = NULL;
-    char *name, *origxml = NULL;
+    const char *name;
+    char *origxml = NULL;
     xmlChar *newxml = NULL;
     int found;
     int ret = FALSE;
@@ -6959,7 +6962,7 @@
 {
     virStorageVolPtr vol;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -7000,7 +7003,7 @@
 {
     virStorageVolPtr vol;
     int ret = TRUE;
-    char *name;
+    const char *name;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -7537,7 +7540,7 @@
 cmdVolPath(vshControl *ctl, const vshCmd *cmd)
 {
     virStorageVolPtr vol;
-    char *name = NULL;
+    const char *name = NULL;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -7569,7 +7572,8 @@
 static int
 cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
 {
-    char *from, *buffer;
+    const char *from;
+    char *buffer;
     virSecretPtr res;
     char uuid[VIR_UUID_STRING_BUFLEN];

@@ -7660,7 +7664,8 @@
 {
     virSecretPtr secret;
     size_t value_size;
-    char *base64, *value;
+    const char *base64;
+    char *value;
     int found, res, ret = FALSE;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -7770,7 +7775,7 @@
 {
     virSecretPtr secret;
     int ret = FALSE;
-    char *uuid;
+    const char *uuid;

     if (!vshConnectionUsability(ctl, ctl->conn))
         return FALSE;
@@ -8036,7 +8041,7 @@
 static int
 cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
 {
-    char *cap;
+    const char *cap;
     char **devices;
     int found, num_devices, i;
     int tree = vshCommandOptBool(cmd, "tree");
@@ -8516,7 +8521,7 @@
 cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *from;
+    const char *from;
     char *buffer;
     int ret = TRUE;
     int found;
@@ -8583,7 +8588,7 @@
 cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *from;
+    const char *from;
     char *buffer;
     int ret = TRUE;
     int found;
@@ -8651,7 +8656,7 @@
 cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    char *from;
+    const char *from;
     char *buffer;
     int ret = TRUE;
     int found;
@@ -8727,7 +8732,7 @@
 cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom = NULL;
-    char *mac, *target, *script, *type, *source, *model;
+    const char *mac, *target, *script, *type, *source, *model;
     int typ, ret = FALSE;
     unsigned int flags;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -8837,7 +8842,8 @@
     xmlXPathContextPtr ctxt = NULL;
     xmlNodePtr cur = NULL;
     xmlBufferPtr xml_buf = NULL;
-    char *doc, *mac =NULL, *type;
+    const char *mac =NULL, *type;
+    char *doc;
     char buf[64];
     int i = 0, diff_mac, ret = FALSE;
     unsigned int flags;
@@ -8976,10 +8982,10 @@
 cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom = NULL;
-    char *source, *target, *driver, *subdriver, *type, *mode;
+    const char *source, *target, *driver, *subdriver, *type, *mode;
     int isFile = 0, ret = FALSE;
     unsigned int flags;
-    char *stype;
+    const char *stype;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *xml;

@@ -9104,7 +9110,8 @@
     xmlNodePtr cur = NULL;
     xmlBufferPtr xml_buf = NULL;
     virDomainPtr dom = NULL;
-    char *doc, *target;
+    const char *target;
+    char *doc;
     int i = 0, diff_tgt, ret = FALSE;
     unsigned int flags;

@@ -9221,7 +9228,7 @@
 static int
 cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
 {
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -9285,7 +9292,7 @@
 static int
 cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
 {
-    char *from;
+    const char *from;
     int found;
     int ret = TRUE;
     char *buffer;
@@ -9517,9 +9524,9 @@
 cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
 {
     const char *dir;
+    char *dir_malloced = NULL;
     int found;
     int ret = TRUE;
-    bool dir_malloced = false;

     if (!ctl->imode) {
         vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
@@ -9529,8 +9536,7 @@
     dir = vshCommandOptString(cmd, "dir", &found);
     if (!found) {
         uid_t uid = geteuid();
-        dir = virGetUserDirectory(uid);
-        dir_malloced = !!dir;
+        dir = dir_malloced = virGetUserDirectory(uid);
     }
     if (!dir)
         dir = "/";
@@ -9540,8 +9546,7 @@
         ret = FALSE;
     }

-    if (dir_malloced)
-        VIR_FREE(dir);
+    VIR_FREE(dir_malloced);
     return ret;
 }

@@ -9830,7 +9835,7 @@
 {
     virDomainPtr dom = NULL;
     int ret = FALSE;
-    char *from;
+    const char *from;
     char *buffer = NULL;
     virDomainSnapshotPtr snapshot = NULL;
     xmlDocPtr xml = NULL;
@@ -10103,7 +10108,7 @@
 {
     virDomainPtr dom = NULL;
     int ret = FALSE;
-    char *name;
+    const char *name;
     virDomainSnapshotPtr snapshot = NULL;
     char *xml = NULL;

@@ -10160,7 +10165,7 @@
 {
     virDomainPtr dom = NULL;
     int ret = FALSE;
-    char *name;
+    const char *name;
     virDomainSnapshotPtr snapshot = NULL;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -10213,7 +10218,7 @@
 {
     virDomainPtr dom = NULL;
     int ret = FALSE;
-    char *name;
+    const char *name;
     virDomainSnapshotPtr snapshot = NULL;
     unsigned int flags = 0;

@@ -10270,7 +10275,7 @@
 {
     virDomainPtr dom = NULL;
     int ret = FALSE;
-    char *monitor_cmd;
+    const char *monitor_cmd;
     char *result = NULL;
     unsigned int flags = 0;

@@ -10842,7 +10847,7 @@
 /*
  * Returns option as STRING
  */
-static char *
+static const char *
 vshCommandOptString(const vshCmd *cmd, const char *name, int *found)
 {
     vshCmdOpt *arg = vshCommandOpt(cmd, name);
@@ -10932,10 +10937,10 @@

 static virDomainPtr
 vshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd,
-                      char **name, int flag)
+                      const char **name, int flag)
 {
     virDomainPtr dom = NULL;
-    char *n;
+    const char *n;
     int id;
     const char *optname = "domain";
     if (!cmd_has_option (ctl, cmd, optname))
@@ -10979,10 +10984,10 @@

 static virNetworkPtr
 vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
-                       char **name, int flag)
+                       const char **name, int flag)
 {
     virNetworkPtr network = NULL;
-    char *n;
+    const char *n;
     const char *optname = "network";
     if (!cmd_has_option (ctl, cmd, optname))
         return NULL;
@@ -11018,10 +11023,10 @@

 static virNWFilterPtr
 vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
-                        char **name, int flag)
+                        const char **name, int flag)
 {
     virNWFilterPtr nwfilter = NULL;
-    char *n;
+    const char *n;
     const char *optname = "nwfilter";
     if (!cmd_has_option (ctl, cmd, optname))
         return NULL;
@@ -11056,10 +11061,10 @@

 static virInterfacePtr
 vshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
-                         char **name, int flag)
+                         const char **name, int flag)
 {
     virInterfacePtr iface = NULL;
-    char *n;
+    const char *n;
     const char *optname = "interface";
     if (!cmd_has_option (ctl, cmd, optname))
         return NULL;
@@ -11094,10 +11099,10 @@

 static virStoragePoolPtr
 vshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
-                    char **name, int flag)
+                    const char **name, int flag)
 {
     virStoragePoolPtr pool = NULL;
-    char *n;
+    const char *n;

     if (!(n = vshCommandOptString(cmd, optname, NULL)))
         return NULL;
@@ -11131,11 +11136,11 @@
 vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
                    const char *optname,
                    const char *pooloptname,
-                   char **name, int flag)
+                   const char **name, int flag)
 {
     virStorageVolPtr vol = NULL;
     virStoragePoolPtr pool = NULL;
-    char *n, *p;
+    const char *n, *p;
     int found;

     if (!(n = vshCommandOptString(cmd, optname, NULL)))
@@ -11182,10 +11187,10 @@
 }

 static virSecretPtr
-vshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, char **name)
+vshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
 {
     virSecretPtr secret = NULL;
-    char *n;
+    const char *n;
     const char *optname = "secret";

     if (!cmd_has_option (ctl, cmd, optname))


Rule logging: For 'fast' mode, only log rules with at least one executed action.

--- engine/rule_logger.c
+++ engine/rule_logger.c
@@ -677,13 +677,18 @@
     assert(log_exec->actions != NULL);
     assert(log_exec->tgt_list != NULL);

+    /* If no actions, just return */
+    if (IB_LIST_ELEMENTS(log_exec->actions) == 0) {
+        IB_FTRACE_RET_VOID();
+    }
+
     ib_tx_t *tx = log_exec->tx;
     const ib_rule_t *rule = log_exec->rule;
     ib_time_t now = ib_clock_get_time();
     char actbuf[MAX_ACTBUF + 1];

     build_act_buf(log_exec, actbuf, MAX_ACTBUF);
-
+
     ib_log_tx_ex(tx, IB_LOG_INFO, file, line,
                    "%s %s:%d %"PRIu64"us %s actions=%s",
                    LOG_PREFIX,


added define so RSTRING so it works on 1.8.5

--- ext/typhoeus/native.h
+++ ext/typhoeus/native.h
@@ -12,3 +12,10 @@
 extern void init_typhoeus_multi();

 #endif
+
+#ifndef RSTRING_PTR
+
+#define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#define RSTRING_LEN(s) (RSTRING(s)->len)
+
+#endif


Fixed memory leak from unfreed cache entry.

--- src/basedir.c
+++ src/basedir.c
@@ -153,6 +153,11 @@
 			free(cache->configHome);
 		cache->configHome = 0;
 	}
+	if (cache->cacheHome)
+	{
+		free(cache->cacheHome);
+		cache->cacheHome = 0;
+	}
 	xdgFreeStringList(cache->searchableDataDirectories);
 	cache->searchableDataDirectories = 0;
 	xdgFreeStringList(cache->searchableConfigDirectories);


In sc_set_text_mode(), reset fontwidth if it is <= 0.
Eliminates division by zero errors in syscons driver.

Reported by:	keramida, Slawa Olhovchenkov <slw at zxy dot spb dot ru>,
		Kyryll Mirnenko <mirya at matrix dot kiev dot ua>
Tested by:	keramida, rodrigc

--- sys/dev/syscons/scvidctl.c
+++ sys/dev/syscons/scvidctl.c
@@ -145,6 +145,8 @@
 	return ENODEV;

     /* adjust argument values */
+    if (fontwidth <= 0)
+	fontwidth = info.vi_cwidth;
     if (fontsize <= 0)
 	fontsize = info.vi_cheight;
     if (fontsize < 14) {


ext4: fix up error handling for mpage_map_and_submit_extent()

The function mpage_released_unused_page() must only be called once;
otherwise the kernel will BUG() when the second call to
mpage_released_unused_page() tries to unlock the pages which had been
unlocked by the first call.

Also restructure the error handling so that we only give up on writing
the dirty pages in the case of ENOSPC where retrying the allocation
won't help.  Otherwise, a transient failure, such as a kmalloc()
failure in calling ext4_map_blocks() might cause us to give up on
those pages, leading to a scary message in /var/log/messages plus data
loss.

Signed-off-by: "Theodore Ts'o" <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>
Reviewed-by: Jan Kara <596727c8a0ea4db3ba2ceceedccbacd3d7b371b8@suse.cz>

--- fs/ext4/inode.c
+++ fs/ext4/inode.c
@@ -2153,7 +2153,8 @@
  * guaranteed). After mapping we submit all mapped pages for IO.
  */
 static int mpage_map_and_submit_extent(handle_t *handle,
-				       struct mpage_da_data *mpd)
+				       struct mpage_da_data *mpd,
+				       bool *give_up_on_write)
 {
 	struct inode *inode = mpd->inode;
 	struct ext4_map_blocks *map = &mpd->map;
@@ -2167,29 +2168,30 @@
 		if (err < 0) {
 			struct super_block *sb = inode->i_sb;

+			if (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)
+				goto invalidate_dirty_pages;
 			/*
-			 * Need to commit transaction to free blocks. Let upper
-			 * layers sort it out.
+			 * Let the uper layers retry transient errors.
+			 * In the case of ENOSPC, if ext4_count_free_blocks()
+			 * is non-zero, a commit should free up blocks.
 			 */
-			if (err == -ENOSPC && ext4_count_free_clusters(sb))
-				return -ENOSPC;
-
-			if (!(EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)) {
-				ext4_msg(sb, KERN_CRIT,
-					 "Delayed block allocation failed for "
-					 "inode %lu at logical offset %llu with"
-					 " max blocks %u with error %d",
-					 inode->i_ino,
-					 (unsigned long long)map->m_lblk,
-					 (unsigned)map->m_len, err);
-				ext4_msg(sb, KERN_CRIT,
-					 "This should not happen!! Data will "
-					 "be lost\n");
-				if (err == -ENOSPC)
-					ext4_print_free_blocks(inode);
-			}
-			/* invalidate all the pages */
-			mpage_release_unused_pages(mpd, true);
+			if ((err == -ENOMEM) ||
+			    (err == -ENOSPC && ext4_count_free_clusters(sb)))
+				return err;
+			ext4_msg(sb, KERN_CRIT,
+				 "Delayed block allocation failed for "
+				 "inode %lu at logical offset %llu with"
+				 " max blocks %u with error %d",
+				 inode->i_ino,
+				 (unsigned long long)map->m_lblk,
+				 (unsigned)map->m_len, -err);
+			ext4_msg(sb, KERN_CRIT,
+				 "This should not happen!! Data will "
+				 "be lost\n");
+			if (err == -ENOSPC)
+				ext4_print_free_blocks(inode);
+		invalidate_dirty_pages:
+			*give_up_on_write = true;
 			return err;
 		}
 		/*
@@ -2377,6 +2379,7 @@
 	struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb);
 	bool done;
 	struct blk_plug plug;
+	bool give_up_on_write = false;

 	trace_ext4_writepages(inode, wbc);

@@ -2494,7 +2497,8 @@
 		ret = mpage_prepare_extent_to_map(&mpd);
 		if (!ret) {
 			if (mpd.map.m_len)
-				ret = mpage_map_and_submit_extent(handle, &mpd);
+				ret = mpage_map_and_submit_extent(handle, &mpd,
+					&give_up_on_write);
 			else {
 				/*
 				 * We scanned the whole range (or exhausted
@@ -2509,7 +2513,7 @@
 		/* Submit prepared bio */
 		ext4_io_submit(&mpd.io_submit);
 		/* Unlock pages we didn't use */
-		mpage_release_unused_pages(&mpd, false);
+		mpage_release_unused_pages(&mpd, give_up_on_write);
 		/* Drop our io_end reference we got from init */
 		ext4_put_io_end(mpd.io_submit.io_end);


Added async memcpy driver api for nvcc backend

Change-Id: If401fc949b834c883cff9de74adb0d532a0fd942

--- include/nvcc_detail/hip_runtime_api.h
+++ include/nvcc_detail/hip_runtime_api.h
@@ -230,6 +230,24 @@
             hipDeviceptr_t src, size_t size)
 {
     return hipCUResultTohipError(cuMemcpyDtoD(dst, src, size));
+}
+
+inline static hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst,
+                  void* src, size_t size, hipStream_t stream)
+{
+    return hipCUResultTohipError(cuMemcpyHtoDAsync(dst, src, size, stream));
+}
+
+inline static hipError_t hipMemcpyDtoHAsync(void* dst,
+                  hipDeviceptr_t src, size_t size, hipStream_t stream)
+{
+    return hipCUResultTohipError(cuMemcpyDtoH(dst, src, size, stream));
+}
+
+inline static hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst,
+            hipDeviceptr_t src, size_t size, hipStream_t stream)
+{
+    return hipCUResultTohipError(cuMemcpyDtoD(dst, src, size, stream));
 }

 inline static hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind copyKind) {


comment

comment

--- lnet-lite/libcfs/user-prim.c
+++ lnet-lite/libcfs/user-prim.c
@@ -166,6 +166,9 @@
         return getuid();
 }

+/*
+ * Use environment variables to turn on some socket features.
+ */
 int cfs_parse_int_tunable(int *value, char *name)
 {
         char    *env = getenv(name);


added version

added version

git-svn-id: e459f0f744eb8de3c7d746c582a86482e0e1ba61@36 c806cf25-6737-4204-a6ff-d454d43a9a0d

--- lsignal.c
+++ lsignal.c
@@ -25,6 +25,7 @@
 */

 #define LUA_LIB_NAME      "signal"
+#define LUA_LIB_VERSION   1.1
 #define LUA_SIGNAL_NAME   "LUA_SIGNAL"
 #define LUA_SIGNAL_COUNT  1e4
 #define LUA_SIGNAL_ERROR  1
@@ -339,6 +340,8 @@

   /* add the library */
   luaL_register(L, LUA_LIB_NAME, lib);
+  lua_pushnumber(L, LUA_LIB_VERSION);
+  lua_setfield(L, -2, "version");

   for (i = 0, max_signal = 0; lua_signals[i].name != NULL; i++)
     if (lua_signals[i].sig > max_signal)


GESTimelineObject: Check for valid arguments

and minor indentation fix

--- ges/ges-timeline-object.c
+++ ges/ges-timeline-object.c
@@ -759,12 +759,15 @@
   GList *tmp;
   GESTrackObject *otmp;

+  g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
+  g_return_val_if_fail (GES_IS_TRACK (track), NULL);
+
   for (tmp = object->priv->trackobjects; tmp; tmp = g_list_next (tmp)) {
     otmp = (GESTrackObject *) tmp->data;

     if (ges_track_object_get_track (otmp) == track) {
-      if ((type != G_TYPE_NONE) && !G_TYPE_CHECK_INSTANCE_TYPE (tmp->data,
-              type))
+      if ((type != G_TYPE_NONE) &&
+          !G_TYPE_CHECK_INSTANCE_TYPE (tmp->data, type))
         continue;

       ret = GES_TRACK_OBJECT (tmp->data);


Increase next_loc.

Increase next_loc.

--- fmpz_mpoly/sqrt_heap.c
+++ fmpz_mpoly/sqrt_heap.c
@@ -64,10 +64,10 @@
            FLINT_ABS(bits2) <= 2*(FLINT_BITS - 3);

     /* alloc array of heap nodes which can be chained together */
-    next_loc = len2 + 3;   /* something bigger than heap can ever be */
-    heap = (mpoly_heap1_s *) TMP_ALLOC((next_loc - 1)*sizeof(mpoly_heap1_s));
-    chain = (mpoly_heap_t *) TMP_ALLOC((next_loc - 2)*sizeof(mpoly_heap_t));
-    store = store_base = (slong *) TMP_ALLOC(2*(next_loc - 2)*sizeof(mpoly_heap_t *));
+    next_loc = len2 + 4;   /* something bigger than heap can ever be */
+    heap = (mpoly_heap1_s *) TMP_ALLOC((next_loc - 2)*sizeof(mpoly_heap1_s));
+    chain = (mpoly_heap_t *) TMP_ALLOC((next_loc - 3)*sizeof(mpoly_heap_t));
+    store = store_base = (slong *) TMP_ALLOC(2*(next_loc - 3)*sizeof(mpoly_heap_t *));

     /* mask with high bit set in each field of exponent vector */
     mask = 0;
@@ -402,29 +402,29 @@
     fmpz_init(r);
     fmpz_init(temp);

-   /* if intermediate computations a - c_i*c_j likely fit in three words */
-   bits2 = _fmpz_vec_max_bits(poly2, len2);
-   /* add 1 for sign, 1 for subtraction and 1 for multiplication by 2 */
-   small = FLINT_ABS(bits2) + FLINT_BIT_COUNT(len2) + 3 <= 2*FLINT_BITS &&
+    /* if intermediate computations a - c_i*c_j likely fit in three words */
+    bits2 = _fmpz_vec_max_bits(poly2, len2);
+    /* add 1 for sign, 1 for subtraction and 1 for multiplication by 2 */
+    small = FLINT_ABS(bits2) + FLINT_BIT_COUNT(len2) + 3 <= 2*FLINT_BITS &&
            FLINT_ABS(bits2) <= 2*(FLINT_BITS - 3);

     /* alloc array of heap nodes which can be chained together */
-    next_loc = len2 + 3;   /* something bigger than heap can ever be */
-    heap = (mpoly_heap_s *) TMP_ALLOC((next_loc - 1)*sizeof(mpoly_heap_s));
-    chain = (mpoly_heap_t *) TMP_ALLOC((next_loc - 2)*sizeof(mpoly_heap_t));
-    store = store_base = (slong *) TMP_ALLOC(2*(next_loc - 2)*sizeof(mpoly_heap_t *));
+    next_loc = len2 + 4;   /* something bigger than heap can ever be */
+    heap = (mpoly_heap_s *) TMP_ALLOC((next_loc - 2)*sizeof(mpoly_heap_s));
+    chain = (mpoly_heap_t *) TMP_ALLOC((next_loc - 3)*sizeof(mpoly_heap_t));
+    store = store_base = (slong *) TMP_ALLOC(2*(next_loc - 3)*sizeof(mpoly_heap_t *));

     /* array of exponent vectors, each of "N" words */
-    exps = (ulong *) TMP_ALLOC((next_loc - 2)*N*sizeof(ulong));
+    exps = (ulong *) TMP_ALLOC((next_loc - 3)*N*sizeof(ulong));
     /* list of pointers to available exponent vectors */
-    exp_list = (ulong **) TMP_ALLOC((next_loc - 2)*sizeof(ulong *));
+    exp_list = (ulong **) TMP_ALLOC((next_loc - 3)*sizeof(ulong *));
     /* space to save copy of current exponent vector */
     exp = (ulong *) TMP_ALLOC(N*sizeof(ulong));
     /* final exponent */
     exp3 = (ulong *) TMP_ALLOC(N*sizeof(ulong));
     /* set up list of available exponent vectors */
     exp_next = 0;
-    for (i = 0; i < next_loc - 2; i++)
+    for (i = 0; i < next_loc - 3; i++)
         exp_list[i] = exps + i*N;

     /* mask with high bit set in each word of each field of exponent vector */


Fixed a segfault in the rule logger

Fixed a segfault in the rule logger

--- engine/rule_logger.c
+++ engine/rule_logger.c
@@ -712,7 +712,8 @@
             assert(rslt != NULL);

             /* Only log rule targets that caused an action to execute */
-            if ( (rslt->act_list == NULL) ||
+            if ( (rslt->value == NULL) ||
+                 (rslt->act_list == NULL) ||
                  (ib_list_elements(rslt->act_list) == 0) )
             {
                 continue;


Switch to LAPACK wrapper calls

Switch to LAPACK wrapper calls

--- src/bcv-svd.c
+++ src/bcv-svd.c
@@ -243,7 +243,7 @@
  *           d   := D
  */
 static int
-decompose (bcv_matrix_t *x11, bcv_matrix_t *x12,
+decompose (bcv_matrix_t *x11, bcv_matrix_t *x12,
            bcv_matrix_t *x21, double *d)
 {
     bcv_index_t m, n, mn, m2, n2;
@@ -263,7 +263,7 @@
     int one = 1;
     double dzero = 0.0;
     int i;
-    char *uplo;
+    bcv_matrix_uplo_t uplo;

     assert (m > 0);
     assert (n > 0);
@@ -291,36 +291,32 @@

         x11->data[0] = 1.0;
     }
-    else
-    {
-        /* decompose x11 := Q B P^T */
-        F77_CALL (dgebrd) (&m, &n, x11->data, &(x11->lda), d, e, tauq, taup,
-                           work, &lwork, &info);
-
-        if (info == 0)
-        {
-            /* set x21 := x21 P */
-            F77_CALL (dormbr) ("P", "R", "N", &m2, &n, &m,
-                               x11->data, &(x11->lda), taup,
-                               x21->data, &(x21->lda), work, &lwork, &info);
-            assert (info == 0);
-
-            /* set x12 := Q^T x12 */
-            F77_CALL (dormbr) ("Q", "L", "T", &m, &n2, &n,
-                               x11->data, &(x11->lda), tauq,
-                               x12->data, &(x12->lda), work, &lwork, &info);
-            assert (info == 0);
-
-            /* decompose B = U S V^T
-             *    set x11 := V^T
-             *        x12 := U^T x12
-             */
-            uplo = (m >= n) ? "U" : "L";
-            _bcv_matrix_set_identity (x11);
-            F77_CALL (dbdsqr) (uplo, &mn, &n, &zero, &n2, d, e,
-                               x11->data, &(x11->lda), NULL, &one,
-                               x12->data, &(x12->lda), work, &info);
-        }
+    else
+    {
+        /* decompose x11 := Q B P^T */
+        _bcv_lapack_dgebrd (x11, d, e, tauq, taup, work, lwork);
+
+        /* set x21 := x21 P */
+        _bcv_lapack_dormbr (BCV_MATRIX_VECT_P, BCV_MATRIX_RIGHT,
+                            BCV_MATRIX_NOTRANS, x11, taup, x21,
+                            work, lwork);
+
+        /* set x12 := Q^T x12 */
+        _bcv_lapack_dormbr (BCV_MATRIX_VECT_Q, BCV_MATRIX_LEFT,
+                            BCV_MATRIX_TRANS, x11, tauq, x12,
+                            work, lwork);
+
+        /* decompose B = U S V^T
+         *    set x11 := V^T
+         *        x12 := U^T x12
+         */
+        uplo   = (m >= n) ? BCV_MATRIX_UPPER : BCV_MATRIX_LOWER;
+        x11->m = mn;
+        x11->n = mn;
+        x12->m = mn;
+        x21->n = mn;
+        _bcv_matrix_set_identity (x11);
+        info = _bcv_lapack_dbdsqr (uplo, mn, d, e, x11, NULL, x12, work);
     }

     return info;


Argh!  I updated the version number in the MODULE_DEPEND() thingamagook but not in the actual MODULE_VERSION().  Pass me the pointy hat.

--- sys/fs/pseudofs/pseudofs.c
+++ sys/fs/pseudofs/pseudofs.c
@@ -388,4 +388,4 @@
 	NULL
 };
 DECLARE_MODULE(pseudofs, pseudofs_data, SI_SUB_EXEC, SI_ORDER_FIRST);
-MODULE_VERSION(pseudofs, 2);
+MODULE_VERSION(pseudofs, 3);


ext4: fix ext4_writepage() to achieve data=ordered guarantees

So far ext4_writepage() skipped writing pages that had any delayed or
unwritten buffers attached. When blocksize < pagesize this breaks
data=ordered mode guarantees as we can have a page with one freshly
allocated buffer whose allocation is part of the committing
transaction and another buffer in the page which is delayed or
unwritten. So fix this problem by calling ext4_bio_writepage()
anyway. It will submit mapped buffers and leave others alone.

Signed-off-by: Jan Kara <596727c8a0ea4db3ba2ceceedccbacd3d7b371b8@suse.cz>
Signed-off-by: "Theodore Ts'o" <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>

--- fs/ext4/inode.c
+++ fs/ext4/inode.c
@@ -1976,21 +1976,27 @@
 		len = PAGE_CACHE_SIZE;

 	page_bufs = page_buffers(page);
+	/*
+	 * We cannot do block allocation or other extent handling in this
+	 * function. If there are buffers needing that, we have to redirty
+	 * the page. But we may reach here when we do a journal commit via
+	 * journal_submit_inode_data_buffers() and in that case we must write
+	 * allocated buffers to achieve data=ordered mode guarantees.
+	 */
 	if (ext4_walk_page_buffers(NULL, page_bufs, 0, len, NULL,
 				   ext4_bh_delay_or_unwritten)) {
-		/*
-		 * We don't want to do block allocation, so redirty
-		 * the page and return.  We may reach here when we do
-		 * a journal commit via journal_submit_inode_data_buffers.
-		 * We can also reach here via shrink_page_list but it
-		 * should never be for direct reclaim so warn if that
-		 * happens
-		 */
-		WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) ==
-								PF_MEMALLOC);
 		redirty_page_for_writepage(wbc, page);
-		unlock_page(page);
-		return 0;
+		if (current->flags & PF_MEMALLOC) {
+			/*
+			 * For memory cleaning there's no point in writing only
+			 * some buffers. So just bail out. Warn if we came here
+			 * from direct reclaim.
+			 */
+			WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD))
+							== PF_MEMALLOC);
+			unlock_page(page);
+			return 0;
+		}
 	}

 	if (PageChecked(page) && ext4_should_journal_data(inode))


add 64bit types for gcc and clang.

add 64bit types for gcc and clang.

Signed-off-by: Kim Kulling <ab1850e765cb36d3d392c95b68ac3e34036b2afe@googlemail.com>

--- include/openddlparser/OpenDDLCommon.h
+++ include/openddlparser/OpenDDLCommon.h
@@ -29,6 +29,9 @@
 #include <string>

 #include <string.h>
+#ifndef _WIN32
+#  include <inttypes.h>
+#endif

 #ifdef _MSC_VER
 #   define TAG_DLL_EXPORT __declspec(dllexport)
@@ -67,14 +70,17 @@
 typedef char           int8;
 typedef short          int16;
 typedef int            int32;
-//typedef long           int64;
 typedef unsigned char  uint8;
 typedef unsigned short uint16;
 typedef unsigned int   uint32;
-//typedef unsigned long  uint64;
-
-typedef __int64					int64;
-typedef unsigned __int64		uint64;
+
+#ifdef _WIN32
+typedef __int64           int64;
+typedef unsigned __int64  uint64;
+#else
+typedef int64_t           int64;
+typedef uint64_t          uint64;
+#endif

 enum NameType {
     GlobalName,


Fix my stupidity.

Fix my stupidity.

--- gfs-kernel/src/gfs/rgrp.c
+++ gfs-kernel/src/gfs/rgrp.c
@@ -1173,7 +1173,7 @@
 		recent_rgrp_add(rgd);
 		rgd = gfs_rgrpd_get_next(rgd);
 		if (!rgd)
-			rgd = gfs_rgrpd_get_first(rgd);
+			rgd = gfs_rgrpd_get_first(sdp);
 		forward_rgrp_set(sdp, rgd);
 	}


Small improvement to fmpz_poly_derivative


Remove unused field.

Remove unused field.

Approved by:	scottl (mentor)

--- sys/geom/concat/g_concat.h
+++ sys/geom/concat/g_concat.h
@@ -69,7 +69,6 @@
 };

 struct g_concat_softc {
-	int		sc_flags;	/* flags */
 	u_int		sc_type;	/* provider type */
 	struct g_provider *sc_provider;
 	char		sc_name[16];	/* concat name */


ext4: remove redundant set_buffer_mapped() in ext4_da_get_block_prep()

The map_bh() call will have already set the buffer_head to mapped.

Signed-off-by: Feng Tang <7685a6702c33a8c01ef22193062cb8069601cb3e@intel.com>
Signed-off-by: "Theodore Ts'o" <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>

--- fs/ext4/inode.c
+++ fs/ext4/inode.c
@@ -2502,7 +2502,6 @@
 		 * for partial write.
 		 */
 		set_buffer_new(bh);
-		set_buffer_mapped(bh);
 	}
 	return 0;
 }


[ConstraintSystem] Make `typeCheckParameterDefault` a friend

`typeCheckParameterDefault` needs access to `applySolution`
in order to apply a solution found in `inference from defaults` mode.

--- include/swift/Sema/ConstraintSystem.h
+++ include/swift/Sema/ConstraintSystem.h
@@ -79,6 +79,8 @@
 Optional<constraints::SolutionApplicationTarget>
 typeCheckExpression(constraints::SolutionApplicationTarget &target,
                     OptionSet<TypeCheckExprFlags> options);
+
+Type typeCheckParameterDefault(Expr *&, DeclContext *, Type, bool);

 } // end namespace TypeChecker

@@ -3045,6 +3047,10 @@
   swift::TypeChecker::typeCheckExpression(
       SolutionApplicationTarget &target, OptionSet<TypeCheckExprFlags> options);

+  friend Type swift::TypeChecker::typeCheckParameterDefault(Expr *&,
+                                                            DeclContext *, Type,
+                                                            bool);
+
   /// Emit the fixes computed as part of the solution, returning true if we were
   /// able to emit an error message, or false if none of the fixits worked out.
   bool applySolutionFixes(const Solution &solution);


Correct bounds check in lapic_create().

Correct bounds check in lapic_create().

Submitted by:	"Ted Unangst" tedu at coverity.com


Clear the HRTF state values on allocation

--- alc/hrtf.h
+++ alc/hrtf.h
@@ -80,7 +80,7 @@
 struct DirectHrtfState {
     /* HRTF filter state for dry buffer content */
     ALuint IrSize{0};
-    alignas(16) HrirArray Values;
+    alignas(16) HrirArray Values{};
     al::FlexArray<HrirArray,16> Coeffs;

     DirectHrtfState(size_t numchans) : Coeffs{numchans} { }


* bencode: add bc_read_dict api function;

--- src/bencode.h
+++ src/bencode.h
@@ -7,6 +7,7 @@
 #include <stdint.h>

+void bc_read_dict(FILE *in);
 void bc_read(FILE *in);

 #endif


ext4: cleanup never-used magic numbers from htree code

dx_root_limit() will had some dead code which forced it to always return
20, and dx_node_limit to always return 22 for debugging purposes.
Remove it.

Acked-by: Andreas Dilger <fd4823dd86d134508df78a168e24c446ce7699f3@sun.com>
Signed-off-by: Li Zefan <5dc16b054e85ffba6c8d314d8e55ae95dcab12a5@cn.fujitsu.com>
Signed-off-by: Mingming Cao <89e10773c335857ac236dfae53fd89ae361ca3d4@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>

--- fs/ext4/namei.c
+++ fs/ext4/namei.c
@@ -241,13 +241,13 @@
 {
 	unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) -
 		EXT4_DIR_REC_LEN(2) - infosize;
-	return 0? 20: entry_space / sizeof(struct dx_entry);
+	return entry_space / sizeof(struct dx_entry);
 }

 static inline unsigned dx_node_limit (struct inode *dir)
 {
 	unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0);
-	return 0? 22: entry_space / sizeof(struct dx_entry);
+	return entry_space / sizeof(struct dx_entry);
 }

 /*


- At the top of sleepq_catch_signals() lock the thread and check TDF_NEEDSIGCHK    before doing the very expensive cursig() and related locking.  NEEDSIGCHK    is updated whenever our signal mask change or when a signal is delivered and    should be sufficient to avoid the more expensive tests.  This eliminates    another source of PROC_LOCK contention in multithreaded programs.

--- sys/kern/subr_sleepqueue.c
+++ sys/kern/subr_sleepqueue.c
@@ -385,12 +385,20 @@
 	sc = SC_LOOKUP(wchan);
 	mtx_assert(&sc->sc_lock, MA_OWNED);
 	MPASS(wchan != NULL);
+	/*
+	 * See if there are any pending signals for this thread.  If not
+	 * we can switch immediately.  Otherwise do the signal processing
+	 * directly.
+	 */
+	thread_lock(td);
+	if ((td->td_flags & TDF_NEEDSIGCHK) == 0) {
+		sleepq_switch(wchan, pri);
+		return (0);
+	}
+	thread_unlock(td);
+	mtx_unlock_spin(&sc->sc_lock);
 	CTR3(KTR_PROC, "sleepq catching signals: thread %p (pid %ld, %s)",
 		(void *)td, (long)p->p_pid, td->td_name);
-
-	mtx_unlock_spin(&sc->sc_lock);
-
-	/* See if there are any pending signals for this thread. */
 	PROC_LOCK(p);
 	ps = p->p_sigacts;
 	mtx_lock(&ps->ps_mtx);


ext4: allow the mount options nodelalloc and data=journal

Commit 26092bf ("ext4: use a table-driven handler for mount options")
wrongly disallows the specifying the mount options nodelalloc and
data=journal simultaneously.  This is incorrect; it should have only
disallowed the combination of delalloc and data=journal
simultaneously.

Reported-by: Piotr Sarna <e04df6329c28becd47222445f86e2ac02fcd4f14@partner.samsung.com>
Signed-off-by: "Theodore Ts'o" <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org

--- fs/ext4/super.c
+++ fs/ext4/super.c
@@ -1359,7 +1359,7 @@
 	{Opt_delalloc, EXT4_MOUNT_DELALLOC,
 	 MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT},
 	{Opt_nodelalloc, EXT4_MOUNT_DELALLOC,
-	 MOPT_EXT4_ONLY | MOPT_CLEAR | MOPT_EXPLICIT},
+	 MOPT_EXT4_ONLY | MOPT_CLEAR},
 	{Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM,
 	 MOPT_EXT4_ONLY | MOPT_SET},
 	{Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT |


partly revert revision 184199, because TDF_NEEDSIGCHK is persitent when thread is in kernel mode, it can cause dead loop, now unlock process lock after acquired sleep queue lock and thread lock to avoid the problem. This means TDF_NEEDSIGCHK and TDF_NEEDSUSPCHK must be set with process lock and thread lock being hold at same time.

--- sys/kern/subr_sleepqueue.c
+++ sys/kern/subr_sleepqueue.c
@@ -396,7 +396,6 @@
 		return (0);
 	}

-catch_sig:
 	thread_unlock(td);
 	mtx_unlock_spin(&sc->sc_lock);
 	CTR3(KTR_PROC, "sleepq catching signals: thread %p (pid %ld, %s)",
@@ -416,19 +415,15 @@
 			ret = ERESTART;
 		mtx_unlock(&ps->ps_mtx);
 	}
-	PROC_UNLOCK(p);

 	mtx_lock_spin(&sc->sc_lock);
 	thread_lock(td);
-	if (ret != 0)
-		goto out;
-	if ((td->td_flags & (TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK)) != 0)
-		goto catch_sig;
-
-	sleepq_switch(wchan, pri);
-	return (0);
-
-out:
+	PROC_UNLOCK(p);
+	if (ret == 0) {
+		sleepq_switch(wchan, pri);
+		return (0);
+	}
+
 	/*
 	 * There were pending signals and this thread is still
 	 * on the sleep queue, remove it from the sleep queue.


Fix patch provided in #6554.

Fix patch provided in #6554.

--- src/blocked.c
+++ src/blocked.c
@@ -514,6 +514,13 @@
              * we can safely call signalKeyAsReady() against this key. */
             dictDelete(rl->db->ready_keys,rl->key);

+            /* Even if we are not inside call(), increment the call depth
+             * in order to make sure that keys are expired against a fixed
+             * reference time, and not against the wallclock time. This
+             * way we can lookup an object multiple times (BRPOPLPUSH does
+             * that) without the risk of it being freed in the second
+             * lookup, invalidating the first one.
+             * See https://github.com/antirez/redis/pull/6554. */
             server.call_depth++;
             updateCachedTime(0);

@@ -533,7 +540,7 @@
                 serveClientsBlockedOnKeyByModule(rl);
             }

-            server.call_depth++;
+            server.call_depth--;

             /* Free this item. */
             decrRefCount(rl->key);


ext4: Add stripe= option to /proc/mounts
Add stripe= option to /proc/mounts for ext4 filesystems.

Signed-off-by: Miklos Szeredi <84cd5483a2f9acd1c37251cba7c2908448f221b8@suse.cz>
Signed-off-by: Mingming Cao <89e10773c335857ac236dfae53fd89ae361ca3d4@us.ibm.com>

--- fs/ext4/super.c
+++ fs/ext4/super.c
@@ -741,6 +741,8 @@
 	if (test_opt(sb, I_VERSION))
 		seq_puts(seq, ",i_version");

+	if (sbi->s_stripe)
+		seq_printf(seq, ",stripe=%lu", sbi->s_stripe);
 	/*
 	 * journal mode get enabled in different ways
 	 * So just print the value even if we didn't specify it


Reverse the source/destination parameters to in[6]_pcblookup_hash() in
syncache_respond() for the #ifdef MAC case.

Submitted by:	Tai-hwa Liang <avatar-at-mmlab.cse.yzu.edu.tw>


happy new year

happy new year

--- src/bsdconv.h
+++ src/bsdconv.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Kuan-Chung Chiu <buganini@gmail.com>
+ * Copyright (c) 2009-2011 Kuan-Chung Chiu <buganini@gmail.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above


ext4: write superblock only once on unmount

In some rather rare cases it is possible that ext4 may the superblock
to the media twice. This patch makes sure this does not happen. This
should speed up unmounting in those cases.

Signed-off-by: Artem Bityutskiy <2f96f8cd3e2780a209d0ab27d1b44624d0019d3f@linux.intel.com>
Signed-off-by: "Theodore Ts'o" <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>

--- fs/ext4/super.c
+++ fs/ext4/super.c
@@ -836,9 +836,6 @@
 	destroy_workqueue(sbi->dio_unwritten_wq);

 	lock_super(sb);
-	if (sb->s_dirt)
-		ext4_commit_super(sb, 1);
-
 	if (sbi->s_journal) {
 		err = jbd2_journal_destroy(sbi->s_journal);
 		sbi->s_journal = NULL;
@@ -855,8 +852,10 @@
 	if (!(sb->s_flags & MS_RDONLY)) {
 		EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
 		es->s_state = cpu_to_le16(sbi->s_mount_state);
+	}
+	if (sb->s_dirt || !(sb->s_flags & MS_RDONLY))
 		ext4_commit_super(sb, 1);
-	}
+
 	if (sbi->s_proc) {
 		remove_proc_entry("options", sbi->s_proc);
 		remove_proc_entry(sb->s_id, ext4_proc_root);


If mountnfs returns an error, it will have already freed nam; no need to
free it again.

Reported by:	"Ted Unangst" <tedu@coverity.com>
Approved by:	rwatson (mentor)

--- sys/nfsclient/nfs_vfsops.c
+++ sys/nfsclient/nfs_vfsops.c
@@ -507,7 +507,6 @@
 	if ((error = mountnfs(args, mp, nam, which, path, vpp,
 	    td->td_ucred)) != 0) {
 		printf("nfs_mountroot: mount %s on %s: %d", path, which, error);
-		FREE(nam, M_SONAME);
 		return (error);
 	}
 	(void) copystr(which, mp->mnt_stat.f_mntonname, MNAMELEN - 1, 0);


f2fs: fix incorrectly stat number of inline data inode

We should stat inline data information for temp file in f2fs_tmpfile if we
enable inline_data feature.

Otherwise, inline data stat number will be wrong after this temp file is
evicted.

Signed-off-by: Chao Yu <0cc5db7488e13b393f245aa6263acec5e92fdcc5@samsung.com>
Signed-off-by: Jaegeuk Kim <71255387a32c360dfbe6dfb7aaeb123bf1dc8cb6@kernel.org>

--- fs/f2fs/namei.c
+++ fs/f2fs/namei.c
@@ -693,6 +693,8 @@
 	f2fs_unlock_op(sbi);

 	alloc_nid_done(sbi, inode->i_ino);
+
+	stat_inc_inline_inode(inode);
 	d_tmpfile(dentry, inode);
 	unlock_new_inode(inode);
 	return 0;


Synced with sys/i386/i386/userconfig.c rev 1.169.


GFS2: Use GFP_NOFS when allocating glocks

Normally GFP_KERNEL is ok here, but there is now a rarely used code path
relating to deallocation of unlinked inodes (in certain corner cases)
which if hit at times of memory shortage can cause recursion while
trying to free memory.

One solution would be to try and move the gfs2_glock_get() call so
that it is no longer called while another glock is held, but that
doesn't look at all easy, so GFP_NOFS is the best solution for the
time being.

Signed-off-by: Steven Whitehouse <9801c4ef11586b619a1c43ac9377eea2aee672dd@redhat.com>

--- fs/gfs2/glock.c
+++ fs/gfs2/glock.c
@@ -731,14 +731,14 @@
 		cachep = gfs2_glock_aspace_cachep;
 	else
 		cachep = gfs2_glock_cachep;
-	gl = kmem_cache_alloc(cachep, GFP_KERNEL);
+	gl = kmem_cache_alloc(cachep, GFP_NOFS);
 	if (!gl)
 		return -ENOMEM;

 	memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));

 	if (glops->go_flags & GLOF_LVB) {
-		gl->gl_lksb.sb_lvbptr = kzalloc(GFS2_MIN_LVB_SIZE, GFP_KERNEL);
+		gl->gl_lksb.sb_lvbptr = kzalloc(GFS2_MIN_LVB_SIZE, GFP_NOFS);
 		if (!gl->gl_lksb.sb_lvbptr) {
 			kmem_cache_free(cachep, gl);
 			return -ENOMEM;


Add system call auditing support for sparc64.

Submitted by:	brueffer
Obtained from:	TrustedBSD Project

--- sys/sparc64/sparc64/trap.c
+++ sys/sparc64/sparc64/trap.c
@@ -66,6 +66,7 @@
 #include <sys/uio.h>
 #include <sys/ktrace.h>
 #endif
+#include <security/audit/audit.h>

 #include <vm/vm.h>
 #include <vm/pmap.h>
@@ -593,7 +594,9 @@

 		PTRACESTOP_SC(p, td, S_PT_SCE);

+		AUDIT_SYSCALL_ENTER(code, td);
 		error = (*callp->sy_call)(td, argp);
+		AUDIT_SYSCALL_EXIT(code, td);

 		CTR5(KTR_SYSC, "syscall: p=%p error=%d %s return %#lx %#lx ", p,
 		    error, syscallnames[code], td->td_retval[0],


[GFS2] BZ 217008 fsfuzzer fix.

[GFS2] BZ 217008 fsfuzzer fix.

Update the quilt header comments to match the
code changes.

Change gfs2_lookup_simple to return an error in the case
of a NULL inode.
The callers of gfs2_lookup_simple do not check for NULL
in the no entry case and such would end up dereferencing a NULL ptr.

This fixes:
http://projects.info-pull.com/mokb/MOKB-15-11-2006.html

Signed-off-by: Russell Cattelan <7e8dfd2f3e578e48fcf90e33f85390ba2a64e8e5@redhat.com>
Signed-off-by: Steven Whitehouse <9801c4ef11586b619a1c43ac9377eea2aee672dd@redhat.com>

--- fs/gfs2/inode.c
+++ fs/gfs2/inode.c
@@ -361,8 +361,18 @@
 struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
 {
 	struct qstr qstr;
+	struct inode *inode;
 	gfs2_str2qstr(&qstr, name);
-	return gfs2_lookupi(dip, &qstr, 1, NULL);
+	inode = gfs2_lookupi(dip, &qstr, 1, NULL);
+	/* gfs2_lookupi has inconsistent callers: vfs
+	 * related routines expect NULL for no entry found,
+	 * gfs2_lookup_simple callers expect ENOENT
+	 * and do not check for NULL.
+	 */
+	if (inode == NULL)
+		return ERR_PTR(-ENOENT);
+	else
+		return inode;
 }


[patch 05/14] hpfs: dont call permission()

hpfs_unlink() calls permission() prior to truncating the file.  HPFS
doesn't define a .permission method, so replace with explicit call to
generic_permission().

This is equivalent, except that devcgroup_inode_permission() and
security_inode_permission() are not called.

The truncation is just an implementation detail of the unlink, so
these security checks are unnecessary.

I suspect that even calling generic_permission() is unnecessary, since
we shouldn't mind if the file isn't writable.  But I leave that to the
maintainer to decide.

Signed-off-by: Miklos Szeredi <84cd5483a2f9acd1c37251cba7c2908448f221b8@suse.cz>
CC: Mikulas Patocka <48ca9bee1fffce1977d8537782be3863d5c91b8e@artax.karlin.mff.cuni.cz>

--- fs/hpfs/namei.c
+++ fs/hpfs/namei.c
@@ -415,7 +415,7 @@
 		d_drop(dentry);
 		spin_lock(&dentry->d_lock);
 		if (atomic_read(&dentry->d_count) > 1 ||
-		    permission(inode, MAY_WRITE, NULL) ||
+		    generic_permission(inode, MAY_WRITE, NULL) ||
 		    !S_ISREG(inode->i_mode) ||
 		    get_write_access(inode)) {
 			spin_unlock(&dentry->d_lock);


hpfs: use bitmap_weight()

hpfs: use bitmap_weight()

Use bitmap_weight instead of doing hweight32 for each 32bit in bitmap.

Signed-off-by: Akinobu Mita <3807cf899f217da549814bf6c330d3b6e6819ccf@gmail.com>
Cc: Mikulas Patocka <48ca9bee1fffce1977d8537782be3863d5c91b8e@artax.karlin.mff.cuni.cz>
Cc: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- fs/hpfs/super.c
+++ fs/hpfs/super.c
@@ -14,6 +14,7 @@
 #include <linux/magic.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
+#include <linux/bitmap.h>

 /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */

@@ -115,12 +116,13 @@
 unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
 {
 	struct quad_buffer_head qbh;
-	unsigned *bits;
-	unsigned i, count;
-	if (!(bits = hpfs_map_4sectors(s, secno, &qbh, 4))) return 0;
-	count = 0;
-	for (i = 0; i < 2048 / sizeof(unsigned); i++)
-		count += hweight32(bits[i]);
+	unsigned long *bits;
+	unsigned count;
+
+	bits = hpfs_map_4sectors(s, secno, &qbh, 4);
+	if (!bits)
+		return 0;
+	count = bitmap_weight(bits, 2048 * BITS_PER_BYTE);
 	hpfs_brelse4(&qbh);
 	return count;
 }


[readdir] convert nilfs2

[readdir] convert nilfs2

Signed-off-by: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>

--- fs/nilfs2/dir.c
+++ fs/nilfs2/dir.c
@@ -256,22 +256,18 @@
 	de->file_type = nilfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
 }

-static int nilfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
-{
-	loff_t pos = filp->f_pos;
-	struct inode *inode = file_inode(filp);
+static int nilfs_readdir(struct file *file, struct dir_context *ctx)
+{
+	loff_t pos = ctx->pos;
+	struct inode *inode = file_inode(file);
 	struct super_block *sb = inode->i_sb;
 	unsigned int offset = pos & ~PAGE_CACHE_MASK;
 	unsigned long n = pos >> PAGE_CACHE_SHIFT;
 	unsigned long npages = dir_pages(inode);
 /*	unsigned chunk_mask = ~(nilfs_chunk_size(inode)-1); */
-	unsigned char *types = NULL;
-	int ret;

 	if (pos > inode->i_size - NILFS_DIR_REC_LEN(1))
-		goto success;
-
-	types = nilfs_filetype_table;
+		return 0;

 	for ( ; n < npages; n++, offset = 0) {
 		char *kaddr, *limit;
@@ -281,9 +277,8 @@
 		if (IS_ERR(page)) {
 			nilfs_error(sb, __func__, "bad page in #%lu",
 				    inode->i_ino);
-			filp->f_pos += PAGE_CACHE_SIZE - offset;
-			ret = -EIO;
-			goto done;
+			ctx->pos += PAGE_CACHE_SIZE - offset;
+			return -EIO;
 		}
 		kaddr = page_address(page);
 		de = (struct nilfs_dir_entry *)(kaddr + offset);
@@ -293,35 +288,28 @@
 			if (de->rec_len == 0) {
 				nilfs_error(sb, __func__,
 					    "zero-length directory entry");
-				ret = -EIO;
 				nilfs_put_page(page);
-				goto done;
+				return -EIO;
 			}
 			if (de->inode) {
-				int over;
-				unsigned char d_type = DT_UNKNOWN;
-
-				if (types && de->file_type < NILFS_FT_MAX)
-					d_type = types[de->file_type];
-
-				offset = (char *)de - kaddr;
-				over = filldir(dirent, de->name, de->name_len,
-						(n<<PAGE_CACHE_SHIFT) | offset,
-						le64_to_cpu(de->inode), d_type);
-				if (over) {
+				unsigned char t;
+
+				if (de->file_type < NILFS_FT_MAX)
+					t = nilfs_filetype_table[de->file_type];
+				else
+					t = DT_UNKNOWN;
+
+				if (!dir_emit(ctx, de->name, de->name_len,
+						le64_to_cpu(de->inode), t)) {
 					nilfs_put_page(page);
-					goto success;
+					return 0;
 				}
 			}
-			filp->f_pos += nilfs_rec_len_from_disk(de->rec_len);
+			ctx->pos += nilfs_rec_len_from_disk(de->rec_len);
 		}
 		nilfs_put_page(page);
 	}
-
-success:
-	ret = 0;
-done:
-	return ret;
+	return 0;
 }

 /*
@@ -678,7 +666,7 @@
 const struct file_operations nilfs_dir_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= generic_read_dir,
-	.readdir	= nilfs_readdir,
+	.iterate	= nilfs_readdir,
 	.unlocked_ioctl	= nilfs_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= nilfs_compat_ioctl,


ocfs2: Only bug out in direct io write for reflinked extent.

In ocfs2_direct_IO_get_blocks, we only need to bug out
in case of we are going to write a recounted extent rec.

What a silly bug introduced by me!

Signed-off-by: Tao Ma <0490dca64807924fd58df0b0ee32b99ba7004a61@oracle.com>
Signed-off-by: Joel Becker <823d0e2e55da83c1616b20ae9a15f9456fa076e5@oracle.com>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@kernel.org

--- fs/ocfs2/aops.c
+++ fs/ocfs2/aops.c
@@ -577,8 +577,9 @@
 		goto bail;
 	}

-	/* We should already CoW the refcounted extent. */
-	BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED);
+	/* We should already CoW the refcounted extent in case of create. */
+	BUG_ON(create && (ext_flags & OCFS2_EXT_REFCOUNTED));
+
 	/*
 	 * get_more_blocks() expects us to describe a hole by clearing
 	 * the mapped bit on bh_result().


Accidentally lost this file

Accidentally lost this file

error: pathspec 'h/butbr.h' did not match any file(s) known to git

--- h/butbr.h
+++ h/butbr.h
@@ -0,0 +1,11 @@
+typedef struct {
+    SPFLOAT sr, freq, bw, istor;
+    SPFLOAT lkf, lkb;
+    SPFLOAT a[8];
+    SPFLOAT pidsr, tpidsr;
+} sp_butbr;
+
+int sp_butbr_create(sp_butbr **p);
+int sp_butbr_destroy(sp_butbr **p);
+int sp_butbr_init(sp_data *sp, sp_butbr *p);
+int sp_butbr_compute(sp_data *sp, sp_butbr *p, SPFLOAT *in, SPFLOAT *out);


Comments.

Comments.

--- dos/pdcdisp.c
+++ dos/pdcdisp.c
@@ -19,7 +19,7 @@

 #include <string.h>

-RCSID("$Id: pdcdisp.c,v 1.36 2006/07/17 21:45:15 wmcbrine Exp $");
+RCSID("$Id: pdcdisp.c,v 1.37 2006/07/18 23:11:53 wmcbrine Exp $");

 extern unsigned char atrtab[MAX_ATRTAB];

@@ -42,7 +42,7 @@
   PDC_cursor_on()	- Turns on the hardware cursor.

   PDCurses Description:
-	Turns on the hardware curses, it does nothing if it is already on.
+	Turns on the hardware cursor; does nothing if it is already on.

   PDCurses Return Value:
 	Returns OK upon success, ERR upon failure.


Changed GPoints to compound literals for clarity

--- src/c/clock.c
+++ src/c/clock.c
@@ -65,12 +65,6 @@
     .y = ( -cos_lookup( hour_angle ) * HOUR_HAND_LENGTH / TRIG_MAX_RATIO ) + center_pt.y
   };

-  int32_t min_angle = TRIG_MAX_ANGLE * tm_time.tm_min / 60;
-  GPoint min_hand = (GPoint) {
-    .x = ( sin_lookup( min_angle ) * MIN_HAND_LENGTH / TRIG_MAX_RATIO ) + center_pt.x,
-    .y = ( -cos_lookup( min_angle ) * MIN_HAND_LENGTH / TRIG_MAX_RATIO ) + center_pt.y
-  };
-
   // hour hand
   hand_params = (struct HAND_DRAW_PARAMS) {
     .ctx = ctx,
@@ -85,6 +79,12 @@
     .dot_outline_color = COLOUR_DOT_OUTLINE
   };
   draw_clock_hand( &hand_params );
+
+  int32_t min_angle = TRIG_MAX_ANGLE * tm_time.tm_min / 60;
+  GPoint min_hand = (GPoint) {
+    .x = ( sin_lookup( min_angle ) * MIN_HAND_LENGTH / TRIG_MAX_RATIO ) + center_pt.x,
+    .y = ( -cos_lookup( min_angle ) * MIN_HAND_LENGTH / TRIG_MAX_RATIO ) + center_pt.y
+  };

   // minute hand
   hand_params = (struct HAND_DRAW_PARAMS) {


remove custom function run_model from the model header

--- src/c/model.h
+++ src/c/model.h
@@ -4,7 +4,6 @@
 extern "C" {
 #endif

-const char* run_model(const char* inputs);
 double roundToSignificantFigures(double num, int n);
 double print6(double num);


lmtp client: Handle failures better.

lmtp client: Handle failures better.

--- src/lib-lda/lmtp-client.c
+++ src/lib-lda/lmtp-client.c
@@ -34,6 +34,7 @@
 struct lmtp_client {
 	pool_t pool;
 	const char *mail_from;
+	int refcount;

 	const char *my_hostname;
 	const char *host;
@@ -41,6 +42,7 @@
 	unsigned int port;
 	enum lmtp_client_protocol protocol;
 	enum lmtp_input_state input_state;
+	const char *global_fail_string;

 	struct istream *input;
 	struct ostream *output;
@@ -66,9 +68,11 @@
 	pool_t pool;

 	i_assert(*mail_from == '<');
+	i_assert(*my_hostname != '\0');

 	pool = pool_alloconly_create("lmtp client", 512);
 	client = p_new(pool, struct lmtp_client, 1);
+	client->refcount = 1;
 	client->pool = pool;
 	client->mail_from = p_strdup(pool, mail_from);
 	client->my_hostname = p_strdup(pool, my_hostname);
@@ -93,6 +97,19 @@
 		i_stream_unref(&client->data_input);
 }

+static void lmtp_client_ref(struct lmtp_client *client)
+{
+	pool_ref(client->pool);
+}
+
+static void lmtp_client_unref(struct lmtp_client **_client)
+{
+	struct lmtp_client *client = *_client;
+
+	*_client = NULL;
+	pool_unref(&client->pool);
+}
+
 void lmtp_client_deinit(struct lmtp_client **_client)
 {
 	struct lmtp_client *client = *_client;
@@ -100,13 +117,15 @@
 	*_client = NULL;

 	lmtp_client_close(client);
-	pool_unref(&client->pool);
+	lmtp_client_unref(&client);
 }

 static void lmtp_client_fail(struct lmtp_client *client, const char *line)
 {
 	struct lmtp_rcpt *recipients;
 	unsigned int i, count;
+
+	client->global_fail_string = p_strdup(client->pool, line);

 	recipients = array_get_modifiable(&client->recipients, &count);
 	for (i = client->rcpt_next_receive_idx; i < count; i++) {
@@ -114,12 +133,16 @@
 					       recipients[i].context);
 		recipients[i].failed = TRUE;
 	}
+	client->rcpt_next_receive_idx = count;
+
 	for (i = client->rcpt_next_data_idx; i < count; i++) {
 		if (!recipients[i].failed) {
 			recipients[i].data_callback(FALSE, line,
 						    recipients[i].context);
 		}
 	}
+	client->rcpt_next_data_idx = count;
+
 	lmtp_client_close(client);
 }

@@ -337,15 +360,19 @@
 {
 	const char *line;

+	lmtp_client_ref(client);
 	while ((line = i_stream_read_next_line(client->input)) != NULL) {
-		if (lmtp_client_input_line(client, line) < 0)
+		if (lmtp_client_input_line(client, line) < 0) {
+			lmtp_client_unref(&client);
 			return;
+		}
 	}

 	if (client->input->stream_errno != 0) {
 		errno = client->input->stream_errno;
 		i_error("lmtp client: read() failed: %m");
 	}
+	lmtp_client_unref(&client);
 }

 static void lmtp_client_wait_connect(struct lmtp_client *client)
@@ -369,6 +396,7 @@
 {
 	int ret;

+	lmtp_client_ref(client);
 	o_stream_cork(client->output);
 	if ((ret = o_stream_flush(client->output)) < 0)
 		lmtp_client_fail(client, ERRSTR_TEMP_REMOTE_FAILURE
@@ -376,6 +404,7 @@
 	else if (client->input_state == LMTP_INPUT_STATE_DATA)
 		lmtp_client_send_data(client);
 	o_stream_uncork(client->output);
+	lmtp_client_unref(&client);
 	return ret;
 }

@@ -433,16 +462,22 @@
 	rcpt->data_callback = data_callback;
 	rcpt->context = context;

-	if (client->input_state == LMTP_INPUT_STATE_RCPT_TO)
+	if (client->global_fail_string != NULL)
+		rcpt_to_callback(FALSE, client->global_fail_string, context);
+	else if (client->input_state == LMTP_INPUT_STATE_RCPT_TO)
 		lmtp_client_send_rcpts(client);
 }

 void lmtp_client_send(struct lmtp_client *client, struct istream *data_input)
 {
+	unsigned int rcpt_count = array_count(&client->recipients);
+
 	i_stream_ref(data_input);
 	client->data_input = data_input;

-	if (client->rcpt_next_receive_idx == array_count(&client->recipients)) {
+	if (client->global_fail_string != NULL) {
+		lmtp_client_fail(client, client->global_fail_string);
+	} else if (client->rcpt_next_receive_idx == rcpt_count) {
 		client->input_state++;
 		o_stream_send_str(client->output, "DATA\r\n");
 	}


vaapisink: Fix the conditional pad template creation.

--- gst/vaapi/gstvaapisink.c
+++ gst/vaapi/gstvaapisink.c
@@ -65,13 +65,11 @@
         GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE ","
             GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION,
         "{ ENCODED, NV12, I420, YV12 }") ";"
-#endif
-    GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ";"
-#if GST_CHECK_VERSION(1,3,1)
     GST_VIDEO_CAPS_MAKE_WITH_FEATURES (
         GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION,
-        GST_VIDEO_FORMATS_ALL);
+        GST_VIDEO_FORMATS_ALL) ";"
 #endif
+    GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL);
 /* *INDENT-ON* */

 static GstStaticPadTemplate gst_vaapisink_sink_factory =


Revert "gtk_entry_completion_get_cells: revert returning NULL"

This reverts commit a9a6fb045a0faedb30ffdad4ed979f380c483ebd.

--- gtk/gtkentrycompletion.c
+++ gtk/gtkentrycompletion.c
@@ -843,21 +843,20 @@
 static GList *
 gtk_entry_completion_get_cells (GtkCellLayout *cell_layout)
 {
-  static gboolean warned = FALSE;
-
   GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (cell_layout);
-  GtkCellArea *area;
-
-  if (!warned && completion->priv->text_column != -1)
-    {
-      g_warning ("GtkEntryCompletion: don't call gtk_cell_layout_get_cells() to get "
-                 "the cell renderer that was created by setting 'text-column'.");
-      warned = TRUE;
-    }
-
-  area = gtk_entry_completion_get_area (cell_layout);
-
-  return gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (area));
+
+  if (completion->priv->text_column == -1)
+    {
+      GtkCellArea *area;
+
+      area = gtk_entry_completion_get_area (cell_layout);
+      return gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (area));
+    }
+  else
+    {
+      /* Don't expose the internally created cell renderer */
+      return NULL;
+    }
 }

 static void
@@ -1474,9 +1473,6 @@
  * completion list with just strings. This function will set up @completion
  * to have a list displaying all (and just) strings in the completion list,
  * and to get those strings from @column in the model of @completion.
- *
- * The cell renderer added by this function is managed internally. Do
- * not access or modify it.
  *
  * Any cell renderers that were added to @completion before calling this
  * function will be removed.


Refactor: set zk root directory and get service code.

--- arcus_zk.c
+++ arcus_zk.c
@@ -1039,6 +1039,7 @@
     snprintf(zpath, sizeof(zpath), "%s", arcus_conf.ensemble_list);
     if (arcus_conf.verbose > 2)
         arcus_conf.logger->log(EXTENSION_LOG_DEBUG, NULL, "zk ensemble: %s\n", zpath);
+
     inc_count(1);
     zh = zookeeper_init(zpath, arcus_zk_watcher, arcus_conf.zk_timeout, &myid, 0, 0);
     if (!zh) {
@@ -1055,20 +1056,22 @@
         arcus_exit(zh, EX_PROTOCOL);
     }

-    /* zk root node */
-    zk_root = "/arcus";
-
-    /* Retrieve the service code for this cache node */
-    if (arcus_get_service_code(zh, zk_root) != 0) {
-        arcus_conf.logger->log(EXTENSION_LOG_WARNING, NULL,
-                 "Failed to get the service code for this cache node.\n");
-        arcus_exit(zh, EX_PROTOCOL);
-    }
-    assert(arcus_conf.svc != NULL);
-    if (strlen(arcus_conf.svc) > MAX_SERVICECODE_LENGTH) {
-        arcus_conf.logger->log(EXTENSION_LOG_WARNING, NULL,
-                 "Too long service code. servicecode=%s\n", arcus_conf.svc);
-        arcus_exit(zh, EX_PROTOCOL);
+    /* check zk root directory and get the serice code */
+    if (zk_root == NULL) {
+        zk_root = "/arcus"; /* set zk root directory */
+
+        /* Retrieve the service code for this cache node */
+        if (arcus_get_service_code(zh, zk_root) != 0) {
+            arcus_conf.logger->log(EXTENSION_LOG_WARNING, NULL,
+                     "Failed to get the service code for this cache node.\n");
+            arcus_exit(zh, EX_PROTOCOL);
+        }
+        assert(arcus_conf.svc != NULL);
+        if (strlen(arcus_conf.svc) > MAX_SERVICECODE_LENGTH) {
+            arcus_conf.logger->log(EXTENSION_LOG_WARNING, NULL,
+                     "Too long service code. servicecode=%s\n", arcus_conf.svc);
+            arcus_exit(zh, EX_PROTOCOL);
+        }
     }

     snprintf(zpath, sizeof(zpath), "%s/%s/%s", zk_root, zk_cache_path, arcus_conf.svc);


cleanup: do not set members to null in finalize

--- gtk/gtkimcontextsimple.c
+++ gtk/gtkimcontextsimple.c
@@ -139,7 +139,6 @@
   GtkIMContextSimplePrivate *priv = context_simple->priv;

   g_slist_free_full (priv->tables, g_free);
-  priv->tables = NULL;

   G_OBJECT_CLASS (gtk_im_context_simple_parent_class)->finalize (obj);
 }


gtk: convert keyvals to unicode before committing to the imcontext (cherry picked from commit 1eb0d98d734d96a6612e320d32a2aded423d2746)

--- gtk/gtkimcontextsimple.c
+++ gtk/gtkimcontextsimple.c
@@ -371,7 +371,7 @@
                             gint                n_compose)
 {
   GtkIMContextSimplePrivate *priv = context_simple->priv;
-  gunichar value = 0;
+  guint value = 0;

   if (n_compose == 2)
     {
@@ -382,7 +382,7 @@
             {
             case GDK_KEY_dead_doubleacute:
             case GDK_KEY_space:
-              value = '"'; break;
+              value = GDK_KEY_quotedbl; break;

             case 'a': value = GDK_KEY_adiaeresis; break;
             case 'A': value = GDK_KEY_Adiaeresis; break;
@@ -395,7 +395,7 @@
             case 'u': value = GDK_KEY_udiaeresis; break;
             case 'U': value = GDK_KEY_Udiaeresis; break;
             case 'y': value = GDK_KEY_ydiaeresis; break;
-            case 'Y': value = 0x0178; break; /* should be GDK_KEY_Ydiaeresis ?? */
+            case 'Y': value = GDK_KEY_Ydiaeresis; break;
             }
           break;

@@ -411,7 +411,8 @@

   if (value > 0)
     {
-      gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
+      gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple),
+                                         gdk_keyval_to_unicode (value));
       priv->compose_buffer[0] = 0;

       GTK_NOTE (MISC, g_print ("quartz: U+%04X\n", value));


Update main.c

Update main.c

--- MPU6050/main.c
+++ MPU6050/main.c
@@ -18,7 +18,7 @@

 	const char * gMpufifo = "/tmp/mpu.6050.fifo";
 	mkfifo(gMpufifo, 0777);
-	int fd = open(gMpufifo, O_WRONLY/*|O_NONBLOCK*/);
+	int fd = open(gMpufifo, O_WRONLY|O_NONBLOCK);
 	do{
 		ms_update();
 		printf("yaw = %5.4f\tpitch = %5.4f\troll = %5.4f\ttemperature = %5.4f\n",


Use Adwaita as the default theme

Use Adwaita as the default theme

This ensures that GTK+ applications have a high-quality theme on
all platforms, and look consistent.

--- gtk/gtksettingsprivate.h
+++ gtk/gtksettingsprivate.h
@@ -23,7 +23,7 @@

 G_BEGIN_DECLS

-#define DEFAULT_THEME_NAME      "Raleigh"
+#define DEFAULT_THEME_NAME      "Adwaita"

 void                _gtk_settings_set_property_value_from_rc (GtkSettings            *settings,
                                                               const gchar            *name,


styleproperties: use property, not pspec as key

This allows calling functions on the style property from more places.

--- gtk/gtkstyleproperties.c
+++ gtk/gtkstyleproperties.c
@@ -541,12 +541,12 @@
     }

   priv = props->priv;
-  prop = g_hash_table_lookup (priv->properties, style_prop->pspec);
+  prop = g_hash_table_lookup (priv->properties, style_prop);

   if (!prop)
     {
       prop = property_data_new ();
-      g_hash_table_insert (priv->properties, style_prop->pspec, prop);
+      g_hash_table_insert (priv->properties, (gpointer) style_prop, prop);
     }

   val = property_data_get_value (prop, state);
@@ -842,7 +842,7 @@
     }

   priv = props->priv;
-  prop = g_hash_table_lookup (priv->properties, node->pspec);
+  prop = g_hash_table_lookup (priv->properties, node);

   if (!prop)
     return NULL;
@@ -1022,7 +1022,7 @@
     }

   priv = props->priv;
-  prop = g_hash_table_lookup (priv->properties, node->pspec);
+  prop = g_hash_table_lookup (priv->properties, node);

   if (!prop)
     return;


formatting

formatting

SVN revision: 43111

--- src/lib/ecore/ecore_exe.c
+++ src/lib/ecore/ecore_exe.c
@@ -7,8 +7,8 @@
 #endif

 #if defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__)
-#include <sys/time.h>
-#include <sys/resource.h>
+# include <sys/time.h>
+# include <sys/resource.h>
 #endif

 #include <stdlib.h>


Delete catcoin.h

Delete catcoin.h

--- src/catcoin.h
+++ src/catcoin.h
@@ -1,36 +0,0 @@
-// Copyright (c) 2014 Troy Benjegerdes, under AGPLv3
-// Distributed under the Affero GNU General public license version 3
-// file COPYING or http://www.gnu.org/licenses/agpl-3.0.html
-#ifndef CODECOIN_catcoin_H
-#define CODECOIN_catcoin_H
-
-static const int RPC_PORT = 9932;
-static const int RPC_PORT_TESTNET = 19932;
-static const int P2P_PORT = 9933;
-static const int P2P_PORT_TESTNET = 19933;
-
-static const int64_t COIN = 100000000;
-static const int64_t CENT = 1000000;
-
-/** Dust Soft Limit, allowed with additional fee per output */
-static const int64_t DUST_SOFT_LIMIT = 100000; // 0.001 CAT
-/** Dust Hard Limit, ignored as wallet inputs (mininput default) */
-static const int64_t DUST_HARD_LIMIT = 1000;   // 0.00001 CAT mininput
-/** No amount larger than this (in satoshi) is valid */
-static const int64_t MAX_MONEY = 21000000 * COIN;
-inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
-
-/** The interval over which we look to calculate the next difficulty **/
-static const int RETARGET_INTERVAL = 36;
-/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
-static const int COINBASE_MATURITY = 100;
-
-/** Minimum block time spacing (hard limit) **/
-static const int64_t MINIMUM_BLOCK_SPACING = 60;	// Absolute minimum spacing
-
-#define BRAND "CatCoin"
-#define BRAND_upper "CatCoin"
-#define BRAND_lower "catcoin"
-#define LITECOIN_SCRYPT_POWHASH
-
-#endif


since n->filename became non-stringshared only after 1.1 - no
changelog needed, but fix eina waring! (thanks shinwoo!!!)

git-svn-id: a6113611d365f0fc061992be0d1d0b451b434026@68256 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/eina_file_win32.c
+++ src/lib/eina_file_win32.c
@@ -454,8 +454,6 @@

    CloseHandle(file->fm);
    CloseHandle(file->handle);
-
-   eina_stringshare_del(file->filename);

    free(file);
 }