Define CRT abort correctly for VS 2005-2010

Microsoft broke the definition of abort in stdlib.h in Visual Studio
2005, finally fixing it in Visual Studio 2012.

--- byterun/misc.c
+++ byterun/misc.c
@@ -14,6 +14,16 @@
 /**************************************************************************/

 #define CAML_INTERNALS
+
+#if _MSC_VER >= 1400 && _MSC_VER < 1700
+/* Microsoft introduced a regression in Visual Studio 2005 (technically it's
+   not present in the Windows Server 2003 SDK which has a pre-release version)
+   and the abort function ceased to be declared __declspec(noreturn). This was
+   fixed in Visual Studio 2012. Trick stdlib.h into not defining abort (this
+   means exit and _exit are not defined either, but they aren't required). */
+#define _CRT_TERMINATE_DEFINED
+__declspec(noreturn) void __cdecl abort(void);
+#endif

 #include <stdio.h>
 #include <string.h>


both2 seems to be error free.  Good evidence of convergence and optimality.

The bug was that for the W,S fluxes one needs to check that the i,j value is
not on the boundary.  Convergence is on LAYER.  Optimality on LAYER and GLAZE
is for GMRES+GMG+GSsmoothing, GMRES+GMG+ILUsmoothing respectively.  See top
block of comments.

--- c/ch11/both2.c
+++ c/ch11/both2.c
@@ -22,6 +22,19 @@
 2. looks like same scaling as fish.c for NOWIND with eps=1.0:
 ./both2 -b2_problem nowind -b2_eps 1.0 -ksp_view_mat ::ascii_dense
 ../ch6/fish -ksp_view_mat ::ascii_dense
+
+3. convergence at O(h^2) and apparent optimal order for LAYER with GMRES+GMG with GS smoothing and CENTERED on fine grid but otherwise first-order upwinding:
+for LEV in 5 6 7 8 9 10; do
+    ./both2 -snes_type ksponly -b2_limiter centered -b2_none_on_down -b2_problem layer -da_refine $LEV -ksp_converged_reason -pc_type mg -mg_levels_ksp_type richardson -mg_levels_pc_type sor -mg_levels_pc_sor_forward
+done
+
+4. visualize GLAZE but on a 1025x1025 grid using GMRES+GMG with ILU smoothing:
+./both2 -b2_eps 0.005 -b2_limiter none -b2_problem glaze -snes_converged_reason -ksp_converged_reason -pc_type mg -mg_levels_ksp_type richardson -mg_levels_pc_type ilu -snes_monitor_solution draw -draw_pause 1 -da_refine 9
+
+5. evidence of optimality for GLAZE using GMRES+GMG with ILU smoothing and a 33x33 coarse grid:
+for LEV in 5 6 7 8 9 10; do
+    ./both2 -b2_eps 0.005 -b2_limiter centered -b2_none_on_down -b2_problem glaze -snes_type ksponly -ksp_converged_reason -pc_type mg -mg_levels_ksp_type richardson -mg_levels_pc_type ilu -da_refine $LEV -pc_mg_levels $(( $LEV - 3 ))
+done
 */

 #include <petsc.h>
@@ -263,7 +276,7 @@
 */
 PetscErrorCode FormFunctionLocal(DMDALocalInfo *info, double **au,
                                  double **aF, AdCtx *usr) {
-    int          i, j, p, di, dj;
+    int          i, j, p;
     double       hx, hy, hx2, hy2, scF, scBC,
                  x, y, uE, uW, uN, uS, uxx, uyy,
                  ap, flux, u_up, u_dn, u_far, theta;
@@ -287,11 +300,11 @@
             if (i == 0 || i == info->mx-1 || j == 0 || j == info->my-1) {
                 aF[j][i] = scBC * (au[j][i] - (*usr->b_fcn)(x,y,usr));
             } else {
-                uE = (i+1 == info->mx-1) ? (*usr->b_fcn)(x+hx,y,usr) : au[j][i+1];
-                uW = (i-1 == 0)          ? (*usr->b_fcn)(x-hx,y,usr) : au[j][i-1];
+                uE = (i+1 == info->mx-1) ? (*usr->b_fcn)(1.0,y,usr) : au[j][i+1];
+                uW = (i-1 == 0)          ? (*usr->b_fcn)(-1.0,y,usr) : au[j][i-1];
                 uxx = (uE - 2.0 * au[j][i] + uW) / hx2;
-                uN = (j+1 == info->my-1) ? (*usr->b_fcn)(x,y+hy,usr) : au[j+1][i];
-                uS = (j-1 == 0)          ? (*usr->b_fcn)(x,y-hy,usr) : au[j-1][i];
+                uN = (j+1 == info->my-1) ? (*usr->b_fcn)(x,1.0,usr) : au[j+1][i];
+                uS = (j-1 == 0)          ? (*usr->b_fcn)(x,-1.0,usr) : au[j-1][i];
                 uyy = (uN - 2.0 * au[j][i] + uS) / hy2;
                 aF[j][i] = scF * (- usr->eps * (uxx + uyy) - (*usr->g_fcn)(x,y,usr));
             }
@@ -300,7 +313,7 @@

     // for each E,N face of an *owned* cell at (x,y) and (i,j), compute flux at
     //     the face center and then add that to the correct residual
-    // note -1 starts to get W,S faces of owned cells living on ownership
+    // note start offset of -1; gets W,S faces of owned cells living on ownership
     //     boundaries for i,j resp.
     for (j=info->ys-1; j<info->ys+info->ym; j++) {
         y = -1.0 + j * hy;
@@ -315,51 +328,40 @@
             // get E (p=0) and N (p=1) cell face-center flux contributions
             for (p = 0; p < 2; p++) {
                 // get pth component of wind
-                di = (p == 0) ? 1 : 0;  // on other side of face
-                dj = (p == 1) ? 1 : 0;
-                ap = wind_a(x + hx * di / 2.0, y + hy * dj / 2.0, p,usr);
-                // get first-order upwind flux
-                if (ap >= 0.0) {
-                    u_up = au[j][i];
-                } else {
-                    if (i+di == info->mx-1) {
-                        u_up = (*usr->b_fcn)(x+hx,y,usr);
-                    } else if (j+dj == info->my-1) {
-                        u_up = (*usr->b_fcn)(x,y+hy,usr);
+                if (p == 0)
+                    ap = wind_a(x+hx/2.0,y,p,usr);  // x-comp of wind at E
+                else  // p == 1
+                    ap = wind_a(x,y+hy/2.0,p,usr);  // y-comp of wind at N
+                // get locations determined by wind direction
+                if (p == 0)
+                    if (ap >= 0.0) {
+                        u_up = (i == 0) ? (*usr->b_fcn)(-1.0,y,usr) : au[j][i];
+                        u_dn = (i+1 == info->mx-1) ? (*usr->b_fcn)(1.0,y,usr) : au[j][i+1];
+                        u_far = (i-1 <= 0) ? (*usr->b_fcn)(-1.0,y,usr) : au[j][i-1];
                     } else {
-                        u_up = au[j+dj][i+di];
+                        u_up = (i+1 == info->mx-1) ? (*usr->b_fcn)(1.0,y,usr) : au[j][i+1];
+                        u_dn = (i == 0) ? (*usr->b_fcn)(-1.0,y,usr) : au[j][i];
+                        u_far = (i+2 >= info->mx-1) ? (*usr->b_fcn)(1.0,y,usr) : au[j][i+2];
                     }
-                }
+                else  // p == 1
+                    if (ap >= 0.0) {
+                        u_up = (j == 0) ? (*usr->b_fcn)(x,-1.0,usr) : au[j][i];
+                        u_dn = (j+1 == info->my-1) ? (*usr->b_fcn)(x,1.0,usr) : au[j+1][i];
+                        u_far = (j-1 <= 0) ? (*usr->b_fcn)(x,-1.0,usr) : au[j-1][i];
+                    } else {
+                        u_up = (j+1 == info->my-1) ? (*usr->b_fcn)(x,1.0,usr) : au[j+1][i];
+                        u_dn = (j == 0) ? (*usr->b_fcn)(x,-1.0,usr) : au[j][i];
+                        u_far = (j+2 >= info->my-1) ? (*usr->b_fcn)(x,1.0,usr) : au[j+2][i];
+                    }
+                // first-order upwind flux
                 flux = ap * u_up;
                 // flux correction if have limiter
-                if (limiter != NULL) {
-                    if (p == 0)
-                        if (ap >= 0.0)
-                            u_dn = (i+1 == info->mx-1) ? (*usr->b_fcn)(x+hx,y,usr) : au[j][i+1];
-                        else
-                            u_dn = au[j][i];
-                    else  // p == 1
-                        if (ap >= 0.0)
-                            u_dn = (j+1 == info->my-1) ? (*usr->b_fcn)(x,y+hy,usr) : au[j+1][i];
-                        else
-                            u_dn = au[j][i];
-                    if (u_dn != u_up) {
-                        if (p == 0)
-                            if (ap >= 0.0)
-                                u_far = (i-1 <= 0) ? (*usr->b_fcn)(-1.0,y,usr) : au[j][i-1];
-                            else
-                                u_far = (i+2 >= info->mx-1) ? (*usr->b_fcn)(1.0,y,usr) : au[j][i+2];
-                        else  // p == 1
-                            if (ap >= 0.0)
-                                u_far = (j-1 <= 0) ? (*usr->b_fcn)(x,-1.0,usr) : au[j-1][i];
-                            else
-                                u_far = (j+2 >= info->my-1) ? (*usr->b_fcn)(x,1.0,usr) : au[j+2][i];
-                        theta = (u_up - u_far) / (u_dn - u_up);
-                        flux += ap * (*limiter)(theta) * (u_dn - u_up);
-                    }
+                if (limiter != NULL && u_dn != u_up) {
+                    theta = (u_up - u_far) / (u_dn - u_up);
+                    flux += ap * (*limiter)(theta) * (u_dn - u_up);
                 }
-                // update non-boundary and owned F_ij on both sides of computed flux
-                // note aF[]: 1) does not have stencil width, 2) is scaled by scF = hx * hy
+                // update non-boundary and owned residual F_ij on both sides of computed flux
+                // note: 1) aF[] does not have stencil width, 2) F_ij is scaled by scF = hx * hy
                 switch (p) {
                     case 0:  // flux at E
                         if (i > 0 && i >= info->xs)


but mem alignment is not the issue

but mem alignment is not the issue

nstime diff: 0.084484330 seconds
nstime diff: 0.083756024 seconds
nstime diff: 0.084780037 seconds

--- c/mandelbrot.c
+++ c/mandelbrot.c
@@ -174,14 +174,11 @@
 		for (_y=0; _y<h; _y++) {
 		    // 2*sizeof(complex_double) but calculating manually right now
 #define MEMSIZ 32
-		    char mem[MEMSIZ];
-		    // XXX unsigned long, hm. WORD, please.
-		    void *memaligned = CAST(void*, CAST(unsigned long,mem) & ~ 15);
-		    complex_double *p = memaligned;
-		    p->r= inscreen(0,w,_x, fromx, tox);
-		    p->i= inscreen(0,h,_y, fromy, toy);
+		    complex_double p;
+		    p.r= inscreen(0,w,_x, fromx, tox);
+		    p.i= inscreen(0,h,_y, fromy, toy);
 		    {
-			int d= mandelbrotDepth(depth, p);
+			int d= mandelbrotDepth(depth, &p);
 			unsigned char l= d * 255 / depth;
 			setPoint(ctx, _x, _y, l,l,l);
 		    }


Fix warning detected by GCC 6.1.0

Fix warning detected by GCC 6.1.0

--- driverSocBcm2835/src/driverIntcBcm2835/c/bcm2835_intc.c
+++ driverSocBcm2835/src/driverIntcBcm2835/c/bcm2835_intc.c
@@ -90,7 +90,7 @@
 				{1<<28, INTERRUPT_DMA12},
 				{1<<29, INTERRUPT_AUX},
 				{1<<30, INTERRUPT_ARM},
-				{1<<31, INTERRUPT_VPUDMA}
+				{0x8000000u, INTERRUPT_VPUDMA}
 		},
 		// IRQ 2
 		{
@@ -125,7 +125,7 @@
 				{1<<28, INTERRUPT_CPG},
 				{1<<29, INTERRUPT_RNG},
 				{1<<30, INTERRUPT_VC_ARASANSDIO},
-				{1<<31, INTERRUPT_AVSPMON}
+				{0x8000000u, INTERRUPT_AVSPMON}
 		}
 };


yep. Trying to use simd just prevents gcc from optimizing, it seems

--- c/mandelbrot.c
+++ c/mandelbrot.c
@@ -49,7 +49,7 @@

 STATIC void
 magnitudesquare (double*res, complex_double*x) {
-#ifdef USE_SIMD
+#ifdef USE_SIMD_off
     v2_double *xv= CAST(v2_double*,x);
     v2_double xv2 = *xv * *xv;
     *res= Cr(xv2) + Ci(xv2);
@@ -64,7 +64,7 @@
 complex_double_square(complex_double*res, complex_double*x) {
     double r= x->r;
     double i= x->i;
-#ifdef USE_SIMD
+#ifdef USE_SIMD_off
     v2_double *xv= CAST(v2_double*,x);
     {
 	v2_double xv2 = *xv * *xv;
@@ -82,7 +82,7 @@

 STATIC void
 complex_double_add(complex_double*res, complex_double*a, complex_double*b) {
-#ifdef USE_SIMD_hu_slower_thannotusing
+#ifdef USE_SIMD_off
     V2(a);
     V2(b);
     V2(res);


Try to check for a full disk ahead of time.

--- bin/tsdfx/copy.c
+++ bin/tsdfx/copy.c
@@ -34,6 +34,12 @@
 #include <sys/stat.h>
 #include <sys/wait.h>

+#if HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#else
+#undef HAVE_STATVFS
+#endif
+
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
@@ -350,6 +356,9 @@
 tsdfx_copy_wrap(const char *name, const char *srcdir, const char *dstdir,
     const char *files)
 {
+#if HAVE_STATVFS
+	struct statvfs st;
+#endif
 	struct stat srcst, dstst;
 	char srcpath[PATH_MAX], *sf, dstpath[PATH_MAX], *df;
 	size_t slen, dlen, maxlen;
@@ -400,16 +409,28 @@
 			/*
 			 * Attempt to avoid unnecessarily starting a
 			 * copier child for a file that's already been
-			 * copied.  This will not always succeed - the
-			 * permissions check does not take umask into
-			 * account and the size check is meaningless for
-			 * directories.
+			 * copied.
+			 * XXX the permissions check should take umask
+			 * into account.
 			 */
-			if (srcst.st_size == dstst.st_size &&
+			if (S_ISREG(srcst.st_mode) &&
+			    srcst.st_size == dstst.st_size &&
 			    srcst.st_mode == dstst.st_mode &&
 			    srcst.st_mtime == dstst.st_mtime)
 				continue;
+			if (S_ISDIR(srcst.st_mode) &&
+			    srcst.st_mode == dstst.st_mode)
+				continue;
+		} else {
+			memset(&dstst, 0, sizeof dstst);
 		}
+#if HAVE_STATVFS
+		/* check for available space */
+		if (!S_ISDIR(srcst.st_mode) &&
+		    srcst.st_size > dstst.st_size && statvfs(dstdir, &st) == 0 &&
+		    (off_t)(st.f_bavail * st.f_bsize) < srcst.st_size - dstst.st_size)
+			continue;
+#endif
 		if (tsdfx_copy_find(0, srcpath, dstpath) < 0)
 			tsdfx_copy_new(name, srcpath, dstpath);
 	}


Command interface bugfix

Command interface bugfix

--- canopend/src/CO_command.c
+++ canopend/src/CO_command.c
@@ -503,7 +503,7 @@
                 }

                 /* sdo_block <value> */
-                if(strcmp(token, "sdo_block") == 0) {
+                else if(strcmp(token, "sdo_block") == 0) {
                     uint8_t blk;

                     token = getTok(NULL, spaceDelim, &err);


MMDevice: whitespace changes only: formatted documentation a bit better

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@15485 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- MMDevice/MMDevice.h
+++ MMDevice/MMDevice.h
@@ -255,7 +255,8 @@
       virtual int GetPropertyType(const char* name, MM::PropertyType& pt) const = 0;
       virtual unsigned GetNumberOfPropertyValues(const char* propertyName) const = 0;
       virtual bool GetPropertyValueAt(const char* propertyName, unsigned index, char* value) const = 0;
-      /* Sequences can be used for fast acquisitions, sycnchronized by TTLs rather than
+      /**
+       * Sequences can be used for fast acquisitions, sycnchronized by TTLs rather than
        * computer commands.
        * Sequences of states can be uploaded to the device.  The device will cycle through
        * the uploaded list of states (triggered by an external trigger - most often coming
@@ -263,27 +264,27 @@
        * be true
        */
       virtual int IsPropertySequenceable(const char* name, bool& isSequenceable) const = 0;
-      /*
+      /**
        * The largest sequence that can be stored in the device
        */
       virtual int GetPropertySequenceMaxLength(const char* propertyName, long& nrEvents) const = 0;
-      /*
+      /**
        * Starts execution of the sequence
        */
       virtual int StartPropertySequence(const char* propertyName) = 0;
-      /*
+      /**
        * Stops execution of the device
        */
       virtual int StopPropertySequence(const char* propertyName) = 0;
-      /*
+      /**
        * remove previously added sequence
        */
       virtual int ClearPropertySequence(const char* propertyName) = 0;
-      /*
+      /**
        * Add one value to the sequence
        */
       virtual int AddToPropertySequence(const char* propertyName, const char* value) = 0;
-      /*
+      /**
        * Signal that we are done sending sequence values so that the adapter can send the whole sequence to the device
        */
       virtual int SendPropertySequence(const char* propertyName) = 0;
@@ -294,7 +295,7 @@
       virtual void SetDelayMs(double delay) = 0;
       virtual bool UsesDelay() = 0;

-      /*
+      /**
        * library handle management (for use only in the client code)
        */
       // TODO Get/SetModuleHandle() is no longer used; can remove at a
@@ -542,7 +543,7 @@
        */
       virtual void RemoveTag(const char* key) = 0;

-      /*
+      /**
        * Returns whether a camera's exposure time can be sequenced.
        * If returning true, then a Camera adapter class should also inherit
        * the SequenceableExposure class and implement its methods.
@@ -632,7 +633,7 @@
        */
       virtual int GetFocusDirection(FocusDirection& direction) = 0;

-      /*
+      /**
        * Returns whether a stage can be sequenced (synchronized by TTLs)
        * If returning true, then a Stage class should also inherit
        * the SequenceableStage class and implement its methods.
@@ -653,11 +654,18 @@
       virtual int GetStageSequenceMaxLength(long& nrEvents) const = 0;
       virtual int StartStageSequence() = 0;
       virtual int StopStageSequence() = 0;
-      // Remove all values in the sequence
+      /**
+       * Remove all values in the sequence
+       */
       virtual int ClearStageSequence() = 0;
-      // Add one value to the sequence
+      /**
+       * Add one value to the sequence
+       */
       virtual int AddToStageSequence(double position) = 0;
-      // Signal that we are done sending sequence values so that the adapter can send the whole sequence to the device
+      /**
+       * Signal that we are done sending sequence values so that the adapter
+       * can send the whole sequence to the device
+       */
       virtual int SendStageSequence() = 0;
    };

@@ -714,7 +722,7 @@
       virtual int GetStepLimits(long& xMin, long& xMax, long& yMin, long& yMax) = 0;
       virtual double GetStepSizeXUm() = 0;
       virtual double GetStepSizeYUm() = 0;
-       /*
+      /**
        * Returns whether a stage can be sequenced (synchronized by TTLs)
        * If returning true, then an XYStage class should also inherit
        * the SequenceableXYStage class and implement its methods.
@@ -731,11 +739,18 @@
       virtual int GetXYStageSequenceMaxLength(long& nrEvents) const = 0;
       virtual int StartXYStageSequence() = 0;
       virtual int StopXYStageSequence() = 0;
-      // Remove all values in the sequence
+      /**
+       * Remove all values in the sequence
+       */
       virtual int ClearXYStageSequence() = 0;
-      // Add one value to the sequence
+      /**
+       * Add one value to the sequence
+       */
       virtual int AddToXYStageSequence(double positionX, double positionY) = 0;
-      // Signal that we are done sending sequence values so that the adapter can send the whole sequence to the device
+      /**
+       * Signal that we are done sending sequence values so that the adapter
+       * can send the whole sequence to the device
+       */
       virtual int SendXYStageSequence() = 0;

    };
@@ -952,9 +967,9 @@
        */
       virtual int SetImage(unsigned char * pixels) = 0;

-     /**
-       * Load a 32-bit image into the SLM device adapter.
-       */
+      /**
+      * Load a 32-bit image into the SLM device adapter.
+      */
       virtual int SetImage(unsigned int * pixels) = 0;

       /**
@@ -1095,30 +1110,31 @@
       static const DeviceType Type;

    //Galvo API:
-   /*
-    * Moves the galvo devices to the requested position, activates the light
-    * source, waits for the specified amount of time (in microseconds), and
-    * deactivates the light source
-    */
+
+      /**
+       * Moves the galvo devices to the requested position, activates the light
+       * source, waits for the specified amount of time (in microseconds), and
+       * deactivates the light source
+       */
       virtual int PointAndFire(double x, double y, double time_us) = 0;
       virtual int SetSpotInterval(double pulseInterval_us) = 0;
       virtual int SetPosition(double x, double y) = 0;
       virtual int GetPosition(double& x, double& y) = 0;
       virtual int SetIlluminationState(bool on) = 0;
-      /*
+      /**
        * X range of the device in native units
        */
       virtual double GetXRange() = 0;
-      /*
+      /**
        * Minimum X value for the device in native units
        * Must be implemented if it is not 0.0
        */
       virtual double GetXMinimum() = 0;
-      /*
+      /**
        * Y range of the device in native units
        */
       virtual double GetYRange() = 0;
-      /*
+      /**
        * Minimum Y value for the device in native units
        * Must be implemented if it is not 0.0
        */


Add comment to mm_mul and mv_mul

Add comment to mm_mul and mv_mul


Made the OLPC-patch for the remote Opcodes of Dan Williams upstream. Description in the Changelog

--- OOps/remote.c
+++ OOps/remote.c
@@ -3,7 +3,7 @@

     Copyright (C) 2006 by Barry Vercoe

-    This file is not yet part of Csound.
+    This file is part of Csound.

     The Csound Library is free software; you can redistribute it
     and/or modify it under the terms of the GNU Lesser General Public
@@ -38,6 +38,8 @@

 #define ST(x)   (((REMOTE_GLOBALS*) ((CSOUND*)csound)->remoteGlobals)->x)

+void remote_Cleanup(CSOUND *csound);
+
 void remoteRESET(CSOUND *csound)
 {
     csound->remoteGlobals = NULL;
@@ -46,9 +48,9 @@
 #ifdef HAVE_SOCKETS

  /* get the IPaddress of this machine */
-static void getIpAddress(char *ipaddr, char *ifname)
-{
-
+static int getIpAddress(char *ipaddr, char *ifname)
+{
+    int ret = 1;
 #ifdef WIN32
     /* VL 12/10/06: something needs to go here */
     /* gethostbyname is the real answer; code below id unsafe */
@@ -61,25 +63,26 @@
     memset(&sin, 0, sizeof (struct sockaddr_in));
     memmove(&sin.sin_addr, he->h_addr_list[0], he->h_length);
     strcpy(ipaddr, inet_ntoa (sin.sin_addr));
+    ret = 0;

 #else
     struct ifreq ifr;
-    int fd, i;
-    unsigned char val;
+    int fd;

     fd = socket(AF_INET,SOCK_DGRAM, 0);
     if (fd >= 0) {
       strcpy(ifr.ifr_name, ifname);

-      if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
-        for( i=2; i<6; i++){
-          val = (unsigned char)ifr.ifr_ifru.ifru_addr.sa_data[i];
-          sprintf(ipaddr, "%s%d%s", ipaddr, val, i==5?"":".");
-        }
+      if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
+        char *local;
+        local = inet_ntoa(((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr);
+        strcpy(ipaddr, local);
+        ret = 0;
       }
     }
     close(fd);
 #endif
+    return ret;
 }

 char remoteID(CSOUND *csound)
@@ -88,31 +91,89 @@
     return ST(ipadrs)[len-1];
 }

-static void callox(CSOUND *csound)
-{
-    if (csound->remoteGlobals == NULL)
+static int callox(CSOUND *csound)
+{
+    if (csound->remoteGlobals == NULL) {
       csound->remoteGlobals = csound->Calloc(csound, sizeof(REMOTE_GLOBALS));
+      if (csound->remoteGlobals == NULL) {
+        csound->Message(csound, Str("insufficient memory to initialize remote"
+                        " globals."));
+        goto error;
+      }
+    }

     ST(socksout) = (SOCK*)csound->Calloc(csound,(size_t)MAXREMOTES * sizeof(SOCK));
+    if (ST(socksout) == NULL) {
+      csound->Message(csound, Str("insufficient memory to initialize outgoing "
+                      "socket table."));
+      goto error;
+    }
+
     ST(socksin) = (int*) csound->Calloc(csound,(size_t)MAXREMOTES * sizeof(int));
+    if (ST(socksin) == NULL) {
+      csound->Message(csound, Str("insufficient memory to initialize incoming "
+                      "socket table."));
+      goto error;
+    }
+
     ST(insrfd_list) =
       (int*) csound->Calloc(csound,(size_t)MAXREMOTES * sizeof(int));
+    if (ST(insrfd_list) == NULL) {
+      csound->Message(csound, Str("insufficient memory to initialize "
+                      "insrfd_list."));
+      goto error;
+    }
+
     ST(chnrfd_list) =
       (int*) csound->Calloc(csound,(size_t)MAXREMOTES * sizeof(int));
+    if (ST(chnrfd_list) == NULL) {
+      csound->Message(csound, Str("insufficient memory to initialize "
+                      "chnrfd_list."));
+      goto error;
+    }
+
     ST(insrfd) = (int*) csound->Calloc(csound,(size_t)129 * sizeof(int));
+    if (ST(insrfd) == NULL) {
+      csound->Message(csound, Str("insufficient memory to initialize "
+                      "insrfd table."));
+      goto error;
+    }
+
     ST(chnrfd) = (int*) csound->Calloc(csound,(size_t)17 * sizeof(int));
+    if (ST(chnrfd) == NULL) {
+      csound->Message(csound, Str("insufficient memory to initialize "
+                      "chnrfd table."));
+      goto error;
+    }
+
     ST(ipadrs) = (char*) csound->Calloc(csound,(size_t)15 * sizeof(char));
-
-    getIpAddress(ST(ipadrs), "eth0"); /* get IP adrs of this machine */
+    if (ST(ipadrs) == NULL) {
+      csound->Message(csound, Str("insufficient memory to initialize "
+                      "local ip address."));
+      goto error;
+    }
+
+    /* get IP adrs of this machine */
+    /* FIXME: don't hardcode eth0 */
+    if (getIpAddress(ST(ipadrs), "eth0") < 0) {
+      csound->Message(csound, Str("unable to get local ip address."));
+      goto error;
+    }
+
+    return 0;
+
+error:
+    /* Clean up anything we may have allocated before running out of memory */
+    remote_Cleanup(csound);
+    return -1;
 }

 /* Cleanup the above; called from musmon csoundCleanup */
 void remote_Cleanup(CSOUND *csound)
 {
     int fd;
-/*     if (csound->remoteGlobals == NULL) return; */
-    if (ST(socksout) == NULL) return;     /* if nothing allocated, return */
-    else {
+    if (csound->remoteGlobals == NULL) return;
+    if (ST(socksout) != NULL) {
       SOCK *sop = ST(socksout), *sop_end = sop + MAXREMOTES;
       for ( ; sop < sop_end; sop++)
         if ((fd = sop->rfd) > 0)
@@ -289,7 +350,12 @@
 {   /*      INSTR 0 opcode  */
     short nargs = p->INOCOUNT;

-    if (csound->remoteGlobals==NULL || ST(socksin) == NULL) callox(csound);
+    if (csound->remoteGlobals==NULL || ST(socksin) == NULL) {
+      if (callox(csound) < 0) {
+        csound->InitError(csound, Str("failed to initialize remote globals."));
+        return 0;
+      }
+    }
     if (nargs < 3) {
       csound->InitError(csound, Str("missing instr nos"));
       return 0;
@@ -331,7 +397,12 @@
 {   /*      INSTR 0 opcode  */
     short nargs = p->INOCOUNT;

-    if (csound->remoteGlobals==NULL || ST(socksin) == NULL) callox(csound);
+    if (csound->remoteGlobals==NULL || ST(socksin) == NULL) {
+      if (callox(csound) < 0) {
+        csound->InitError(csound, Str("failed to initialize remote globals."));
+        return 0;
+      }
+    }
     if (nargs < 2) {
       csound->InitError(csound, Str("missing instr nos"));
       return NOTOK;
@@ -361,7 +432,12 @@
 {                                            /* INSTR 0 opcode  */
     short nargs = p->INOCOUNT;

-    if (csound->remoteGlobals==NULL || ST(socksin) == NULL) callox(csound);
+    if (csound->remoteGlobals==NULL || ST(socksin) == NULL) {
+      if (callox(csound) < 0) {
+        csound->InitError(csound, Str("failed to initialize remote globals."));
+        return 0;
+      }
+    }
     if (nargs < 3) {
       csound->InitError(csound, Str("missing channel nos"));
       return NOTOK;
@@ -400,7 +476,12 @@
 {                                         /*       INSTR 0 opcode  */
     short nargs = p->INOCOUNT;

-    if (csound->remoteGlobals==NULL || ST(socksin) == NULL) callox(csound);
+    if (csound->remoteGlobals==NULL || ST(socksin) == NULL) {
+      if (callox(csound) < 0) {
+        csound->InitError(csound, Str("failed to initialize remote globals."));
+        return 0;
+      }
+    }
     if (nargs < 2) {
       csound->InitError(csound, Str("missing channel nos"));
       return NOTOK;


symsync|example: splitting transmit/receive filters

  * allowing separate transmit/receive filters
  * permits GMSK tx/rx filters
  * adding command-line option for filter type selection

--- examples/symsync_crcf_example.c
+++ examples/symsync_crcf_example.c
@@ -4,6 +4,7 @@

 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <math.h>
 #include <getopt.h>
 #include <time.h>
@@ -18,6 +19,7 @@
 {
     printf("symsync_crcf_example [options]\n");
     printf("  u/h   : print usage\n");
+    printf("  T     : filter type: [rrcos], rkaiser, arkaiser, hM3, gmsk\n");
     printf("  k     : filter samples/symbol, default: 2\n");
     printf("  K     : output samples/symbol, default: 2\n");
     printf("  m     : filter delay (symbols), default: 3\n");
@@ -42,7 +44,8 @@
     unsigned int num_filters=32;    // number of filters in the bank
     unsigned int num_symbols=200;   // number of data symbols
     float SNRdB = 30.0f;            // signal-to-noise ratio
-    liquid_rnyquist_type ftype = LIQUID_RNYQUIST_ARKAISER;
+    liquid_rnyquist_type ftype_tx = LIQUID_RNYQUIST_RRC;
+    liquid_rnyquist_type ftype_rx = LIQUID_RNYQUIST_RRC;

     float bt=0.02f;     // loop filter bandwidth
     float tau=-0.1f;     // fractional symbol offset
@@ -52,10 +55,31 @@
     int random_data=1;

     int dopt;
-    while ((dopt = getopt(argc,argv,"uhk:K:m:b:B:s:w:n:t:r:")) != EOF) {
+    while ((dopt = getopt(argc,argv,"uhT:k:K:m:b:B:s:w:n:t:r:")) != EOF) {
         switch (dopt) {
         case 'u':
         case 'h':   usage();                        return 0;
+        case 'T':
+            if (strcmp(optarg,"rrcos")==0) {
+                ftype_tx = LIQUID_RNYQUIST_RRC;
+                ftype_rx = LIQUID_RNYQUIST_RRC;
+            } else if (strcmp(optarg,"rkaiser")==0) {
+                ftype_tx = LIQUID_RNYQUIST_RKAISER;
+                ftype_rx = LIQUID_RNYQUIST_RKAISER;
+            } else if (strcmp(optarg,"arkaiser")==0) {
+                ftype_tx = LIQUID_RNYQUIST_ARKAISER;
+                ftype_rx = LIQUID_RNYQUIST_ARKAISER;
+            } else if (strcmp(optarg,"hM3")==0) {
+                ftype_tx = LIQUID_RNYQUIST_hM3;
+                ftype_rx = LIQUID_RNYQUIST_hM3;
+            } else if (strcmp(optarg,"gmsk")==0) {
+                ftype_tx = LIQUID_RNYQUIST_GMSKTX;
+                ftype_rx = LIQUID_RNYQUIST_GMSKRX;
+            } else {
+                fprintf(stderr,"error: %s, unknown filter type '%s'\n", argv[0], optarg);
+                exit(1);
+            }
+            break;
         case 'k':   k           = atoi(optarg);     break;
         case 'K':   k_out       = atoi(optarg);     break;
         case 'm':   m           = atoi(optarg);     break;
@@ -135,7 +159,7 @@
     // design interpolating filter
     unsigned int h_len = 2*k*m+1;
     float h[h_len];
-    liquid_firdes_rnyquist(ftype,k,m,beta,dt,h);
+    liquid_firdes_rnyquist(ftype_tx,k,m,beta,dt,h);
     interp_crcf q = interp_crcf_create(k,h,h_len);
     for (i=0; i<num_symbols; i++) {
         interp_crcf_execute(q, s[i], &x[n]);
@@ -179,7 +203,7 @@
     // create and run symbol synchronizer
     //

-    symsync_crcf d = symsync_crcf_create_rnyquist(ftype, k, m, beta, num_filters);
+    symsync_crcf d = symsync_crcf_create_rnyquist(ftype_rx, k, m, beta, num_filters);
     symsync_crcf_set_lf_bw(d,bt);
     symsync_crcf_set_output_rate(d,k_out);


warnings in envlpx/linen

warnings in envlpx/linen

--- OOps/ugens1.c
+++ OOps/ugens1.c
@@ -1063,6 +1063,9 @@
     MYFLT a,b,dur;

     if ((dur = *p->idur) > FL(0.0)) {
+      if (*p->irise + *p->idec > dur)
+          csound->Warning(csound, Str("irise greater than idur in linen"));
+
       p->cnt1 = (int32)(*p->iris * CS_EKR + FL(0.5));
       if (p->cnt1 > (int32)0) {
         p->inc1 = FL(1.0) / (MYFLT) p->cnt1;
@@ -1332,6 +1335,8 @@
       }
       else asym = FL(0.0);
       if ((irise = *p->irise) > FL(0.0)) {
+        if (irise + *p->idec > idur)
+          csound->Warning(csound, Str("irise greater than idur in envlpx"));
         p->phs = 0;
         p->ki = (int32) (CS_KICVT / irise);
         p->val = *ftp->ftable;


Improve encoding erlang source code.

Improve encoding erlang source code.

--- erlang_functions_hrl.h
+++ erlang_functions_hrl.h
@@ -231,12 +231,12 @@
 encode_uint8(Value) when is_list(Value) ->
     ValueList = [<<E:8/unsigned-integer-native>> || E <- Value],
     Data = erlang:list_to_binary(ValueList),
-    DataSize = length(ValueList),
+    DataSize = erlang:byte_size(Data),
     <<DataSize:32/unsigned-integer-native, Data/binary>>.

 encode_uint32(Value) when is_list(Value) ->
     ValueList = [<<E:32/unsigned-integer-native>> || E <- Value],
     Data = erlang:list_to_binary(ValueList),
-    DataSize = erlang:length(ValueList),
+    DataSize = erlang:byte_size(Data) div 4,
     <<DataSize:32/unsigned-integer-native, Data/binary>>.


Fix the coordinates of the position of the rotated text

--- DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h
+++ DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h
@@ -227,8 +227,8 @@

 			double dTheta = ((((double)pFont->GetEscapement()) / 10) * M_PI / 180);

-			double dCosTheta = (float)cos(dTheta);
-			double dSinTheta = (float)sin(dTheta);
+			double dCosTheta = cosf(dTheta);
+			double dSinTheta = sinf(dTheta) * -1;

 			float fL = 0, fT = 0, fW = 0, fH = 0;
 			float fUndX1 = 0, fUndY1 = 0, fUndX2 = 0, fUndY2 = 0, fUndSize = 1;
@@ -395,11 +395,14 @@
 				// TODO: тут реализован только параметр shEscapement, еще нужно реализовать параметр Orientation
 				double dM11, dM12, dM21, dM22, dRx, dRy;
 				m_pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dRx, &dRy);
+
+				m_pRenderer->ResetTransform();
+				m_pRenderer->SetTransform(dCosTheta * fabs(dM11), dSinTheta * fabs(dM11), -dSinTheta * fabs(dM22), dCosTheta * fabs(dM22), dRx, dRy);
+
 				double dOldX = dX;
-				dX = dX * dCosTheta - dY * dSinTheta;
-				dY = -(dOldX * dSinTheta + dY * dCosTheta);
-				//Нужно дальше продолжить искать прафильную формулу
-				m_pRenderer->SetTransform(dCosTheta, dSinTheta * fabs(dM11), -dSinTheta * fabs(dM22), -dCosTheta, dRx - dY * dCosTheta, dRy - dX * dSinTheta);
+
+				dX = dX * dSinTheta + dY * dCosTheta + fH * dSinTheta - fH * dCosTheta + fW * dCosTheta;
+				dY = dOldX * dCosTheta - dY * dSinTheta + fH * dSinTheta + fW * dCosTheta;

 				bChangeCTM = true;
 			}


Added constats for heading accuracy thresholds

--- MTLocationDefines.h
+++ MTLocationDefines.h
@@ -29,6 +29,10 @@
 // defined threshold for a location that counts as a location update
 #define kMTLocationMinimumHorizontalAccuracy 1000

+// thresholds to define good/medium/bad heading accuracy
+#define kMTHeadingAccuracyLargeThreshold	45
+#define kMTHeadingAccuracyMediumThreshold	30
+
 // notifications that are sent when BarButtonItem is used as LocationManager-Delegate
 #define kMTLocationManagerDidUpdateToLocationFromLocation	@"kMTLocationManagerDidUpdateToLocationFromLocation"
 #define kMTLocationManagerDidFailWithError					@"kMTLocationManagerDidFailWithError"


git-svn-id: https://www.imagemagick.org/subversion/ImageMagick/trunk@15353 aa41f4f7-0bf4-0310-aa73-e5a19afd5a74

--- MagickCore/effect.c
+++ MagickCore/effect.c
@@ -867,8 +867,9 @@
 %  The format of the EdgeImage method is:
 %
 %      Image *CannyEdgeImage(const Image *image,const double radius,
-%        const double sigma,const double lower_precent,const double upper_percent,
-%        const size_t threshold,ExceptionInfo *exception)
+%        const double sigma,const double lower_precent,
+%        const double upper_percent,const size_t threshold,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %


defensive cecking in setsockopt (coverity)

--- Opcodes/OSC.c
+++ Opcodes/OSC.c
@@ -191,7 +191,10 @@
       if (p->multicast) {
         u_char ttl = 2;
 #if defined(LINUX)
-        setsockopt((long)p->addr, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
+        if (setsockopt((long)p->addr, IPPROTO_IP,
+                       IP_MULTICAST_TTL, &ttl, sizeof(ttl))==-1) {
+          csound->Message, csound, Str("Failed to set multicast");
+        }
 #else
         setsockopt(p->addr, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
 #endif


qemu: checkpoint: split out checkpoint deletion bitmaps

qemuCheckpointDiscard is a massive function that can be separated into
smaller bits. Extract the part that actually modifies the disk from the
metadata handling.

Signed-off-by: Peter Krempa <2cf5c04c61aa466e4a47bfedc747d17279c72ffc@redhat.com>
Reviewed-by: Eric Blake <a9da18479c871fe903d9590822cfe2629c6a4d11@redhat.com>

--- src/qemu/qemu_checkpoint.c
+++ src/qemu/qemu_checkpoint.c
@@ -105,6 +105,81 @@

 static int
+qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
+                             virDomainCheckpointDefPtr chkdef,
+                             bool chkcurrent,
+                             virDomainMomentObjPtr parent)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    virQEMUDriverPtr driver = priv->driver;
+    virDomainMomentObjPtr moment;
+    virDomainCheckpointDefPtr parentdef = NULL;
+    bool search_parents;
+    int rc;
+    g_autoptr(virJSONValue) actions = NULL;
+    size_t i;
+    size_t j;
+
+    if (!(actions = virJSONValueNewArray()))
+        return -1;
+
+    for (i = 0; i < chkdef->ndisks; i++) {
+        virDomainCheckpointDiskDef *disk = &chkdef->disks[i];
+        const char *node;
+
+        if (disk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
+            continue;
+
+        node = qemuDomainDiskNodeFormatLookup(vm, disk->name);
+        /* If any ancestor checkpoint has a bitmap for the same
+         * disk, then this bitmap must be merged to the
+         * ancestor. */
+        search_parents = true;
+        for (moment = parent;
+             search_parents && moment;
+             moment = virDomainCheckpointFindByName(vm->checkpoints,
+                                                    parentdef->parent.parent_name)) {
+            parentdef = virDomainCheckpointObjGetDef(moment);
+            for (j = 0; j < parentdef->ndisks; j++) {
+                virDomainCheckpointDiskDef *disk2;
+                g_autoptr(virJSONValue) arr = NULL;
+
+                disk2 = &parentdef->disks[j];
+                if (STRNEQ(disk->name, disk2->name) ||
+                    disk2->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
+                    continue;
+                search_parents = false;
+
+                if (!(arr = virJSONValueNewArray()))
+                    return -1;
+
+                if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr, node, disk->bitmap) < 0)
+                    return -1;
+
+                if (chkcurrent) {
+                    if (qemuMonitorTransactionBitmapEnable(actions, node, disk2->bitmap) < 0)
+                        return -1;
+                }
+
+                if (qemuMonitorTransactionBitmapMerge(actions, node, disk2->bitmap, &arr) < 0)
+                    return -1;
+            }
+        }
+
+        if (qemuMonitorTransactionBitmapRemove(actions, node, disk->bitmap) < 0)
+            return -1;
+    }
+
+    qemuDomainObjEnterMonitor(driver, vm);
+    rc = qemuMonitorTransaction(priv->mon, &actions);
+    if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
+        return -1;
+
+    return 0;
+}
+
+
+static int
 qemuCheckpointDiscard(virQEMUDriverPtr driver,
                       virDomainObjPtr vm,
                       virDomainMomentObjPtr chk,
@@ -112,9 +187,6 @@
                       bool metadata_only)
 {
     virDomainMomentObjPtr parent = NULL;
-    virDomainMomentObjPtr moment;
-    virDomainCheckpointDefPtr parentdef = NULL;
-    size_t i, j;
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
     g_autofree char *chkFile = NULL;
     bool chkcurrent = chk == virDomainCheckpointGetCurrent(vm->checkpoints);
@@ -129,67 +201,10 @@
                               chk->def->name);

     if (!metadata_only) {
-        qemuDomainObjPrivatePtr priv = vm->privateData;
-        bool search_parents;
         virDomainCheckpointDefPtr chkdef = virDomainCheckpointObjGetDef(chk);
-        int rc;
-        g_autoptr(virJSONValue) actions = NULL;
-
-        if (!(actions = virJSONValueNewArray()))
-            return -1;
-
         parent = virDomainCheckpointFindByName(vm->checkpoints,
                                                chk->def->parent_name);
-        for (i = 0; i < chkdef->ndisks; i++) {
-            virDomainCheckpointDiskDef *disk = &chkdef->disks[i];
-            const char *node;
-
-            if (disk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
-                continue;
-
-            node = qemuDomainDiskNodeFormatLookup(vm, disk->name);
-            /* If any ancestor checkpoint has a bitmap for the same
-             * disk, then this bitmap must be merged to the
-             * ancestor. */
-            search_parents = true;
-            for (moment = parent;
-                 search_parents && moment;
-                 moment = virDomainCheckpointFindByName(vm->checkpoints,
-                                                        parentdef->parent.parent_name)) {
-                parentdef = virDomainCheckpointObjGetDef(moment);
-                for (j = 0; j < parentdef->ndisks; j++) {
-                    virDomainCheckpointDiskDef *disk2;
-                    g_autoptr(virJSONValue) arr = NULL;
-
-                    disk2 = &parentdef->disks[j];
-                    if (STRNEQ(disk->name, disk2->name) ||
-                        disk2->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
-                        continue;
-                    search_parents = false;
-
-                    if (!(arr = virJSONValueNewArray()))
-                        return -1;
-
-                    if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr, node, disk->bitmap) < 0)
-                        return -1;
-
-                    if (chkcurrent) {
-                        if (qemuMonitorTransactionBitmapEnable(actions, node, disk2->bitmap) < 0)
-                            return -1;
-                    }
-
-                    if (qemuMonitorTransactionBitmapMerge(actions, node, disk2->bitmap, &arr) < 0)
-                        return -1;
-                }
-            }
-
-            if (qemuMonitorTransactionBitmapRemove(actions, node, disk->bitmap) < 0)
-                return -1;
-        }
-
-        qemuDomainObjEnterMonitor(driver, vm);
-        rc = qemuMonitorTransaction(priv->mon, &actions);
-        if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
+        if (qemuCheckpointDiscardBitmaps(vm, chkdef, chkcurrent, parent) < 0)
             return -1;
     }


More comments.

More comments.

--- Diminuto/inc/com/diag/diminuto/diminuto_scattergather.h
+++ Diminuto/inc/com/diag/diminuto/diminuto_scattergather.h
@@ -22,7 +22,8 @@
  * A Buffer is a Diminuto Buffer object that is a length field in bytes
  * followed by a continuous section of memory containing the payload.
  * The length field indicates the number of bytes in the payload, not
- * the total size of the Buffer object.
+ * the total size of the Buffer object. (Dimunuto Buffers have their
+ * own length field indicating the total length of the Buffer Object.)
  *
  * A Segment is a Diminuto List node containing a pointer to a Buffer
  * in its payload pointer field.
@@ -35,7 +36,8 @@
  * received.
  *
  * A Pool is a Diminuto list node containing a circular linked list of
- * unused Segments.
+ * unused Segments. (Diminuto Buffers have their own pool of unused
+ * Buffer objects of varying lengths.)
  *
  * SEE ALSO
  *


config: restructure format_config() for better control flow

Commit 578625fa91 (config: add '--name-only' option to list only
variable names, 2015-08-10) modified format_config() such that it
returned from the middle of the function when showing only keys,
resulting in ugly code structure.

Reorganize the if statements and dealing with the key-value delimiter to
make the function easier to read.

Signed-off-by: SZEDER Gábor <46692b1f0516358b02a6405518c0a52aa8fb3e94@ira.uka.de>
Signed-off-by: Junio C Hamano <a6723cc3f76163bf7adb636a73ac3b0ceb3e6b9b@pobox.com>


fs/9p: TREADLINK bugfix

fs/9p: TREADLINK bugfix

Remove v9fs_vfs_readlink_dotl function and use generic_readlink. Update
v9fs_vfs_follow_link_dotl function to accommodate this change

Signed-off-by: M. Mohan Kumar <abee2cb38f12d53e4682bab140e8f4b568816eee@in.ibm.com>
Reported-by:  Dr. David Alan Gilbert <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@treblig.org>
Signed-off-by: Venkateswararao Jujjuri <b575cbb311004fba701c64231d00992dbad0373c@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <f6aaec02cb2023b586fda1596c965a5752b892b4@gmail.com>

--- fs/9p/vfs_inode_dotl.c
+++ fs/9p/vfs_inode_dotl.c
@@ -755,30 +755,6 @@
 	return err;
 }

-static int
-v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
-{
-	int retval;
-	struct p9_fid *fid;
-	char *target = NULL;
-
-	P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
-	retval = -EPERM;
-	fid = v9fs_fid_lookup(dentry);
-	if (IS_ERR(fid))
-		return PTR_ERR(fid);
-
-	retval = p9_client_readlink(fid, &target);
-	if (retval < 0)
-		return retval;
-
-	strncpy(buffer, target, buflen);
-	P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
-
-	retval = strnlen(buffer, buflen);
-	return retval;
-}
-
 /**
  * v9fs_vfs_follow_link_dotl - follow a symlink path
  * @dentry: dentry for symlink
@@ -789,23 +765,33 @@
 static void *
 v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
 {
-	int len = 0;
+	int retval;
+	struct p9_fid *fid;
 	char *link = __getname();
-
-	P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
-
-	if (!link)
+	char *target;
+
+	P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
+
+	if (!link) {
 		link = ERR_PTR(-ENOMEM);
-	else {
-		len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
-		if (len < 0) {
-			__putname(link);
-			link = ERR_PTR(len);
-		} else
-			link[min(len, PATH_MAX-1)] = 0;
-	}
+		goto ndset;
+	}
+	fid = v9fs_fid_lookup(dentry);
+	if (IS_ERR(fid)) {
+		__putname(link);
+		link = ERR_PTR(PTR_ERR(fid));
+		goto ndset;
+	}
+	retval = p9_client_readlink(fid, &target);
+	if (!retval) {
+		strcpy(link, target);
+		kfree(target);
+		goto ndset;
+	}
+	__putname(link);
+	link = ERR_PTR(retval);
+ndset:
 	nd_set_link(nd, link);
-
 	return NULL;
 }

@@ -839,7 +825,7 @@
 };

 const struct inode_operations v9fs_symlink_inode_operations_dotl = {
-	.readlink = v9fs_vfs_readlink_dotl,
+	.readlink = generic_readlink,
 	.follow_link = v9fs_vfs_follow_link_dotl,
 	.put_link = v9fs_vfs_put_link,
 	.getattr = v9fs_vfs_getattr_dotl,


Btrfs: make shrink_delalloc a little friendlier

Xfstests 224 will just sit there and spin for ever until eventually we give up
flushing delalloc and exit.  On my box this took several hours.  I could not
interrupt this process either, even though we use INTERRUPTIBLE.  So do 2 things

1) Keep us from looping over and over again without reclaiming anything
2) If we get interrupted exit the loop

I tested this and the test now exits in a reasonable amount of time, and can be
interrupted with ctrl+c.  Thanks,

Signed-off-by: Josef Bacik <78b342861d821967b29f951b7366f5a0267e0c38@redhat.com>
Signed-off-by: Chris Mason <a169954b4cb1a46cee25f659d3bddfebe02b5fba@oracle.com>

--- fs/btrfs/extent-tree.c
+++ fs/btrfs/extent-tree.c
@@ -3345,8 +3345,10 @@
 	u64 reserved;
 	u64 max_reclaim;
 	u64 reclaimed = 0;
+	long time_left;
 	int pause = 1;
 	int nr_pages = (2 * 1024 * 1024) >> PAGE_CACHE_SHIFT;
+	int loops = 0;

 	block_rsv = &root->fs_info->delalloc_block_rsv;
 	space_info = block_rsv->space_info;
@@ -3359,7 +3361,7 @@

 	max_reclaim = min(reserved, to_reclaim);

-	while (1) {
+	while (loops < 1024) {
 		/* have the flusher threads jump in and do some IO */
 		smp_mb();
 		nr_pages = min_t(unsigned long, nr_pages,
@@ -3367,8 +3369,12 @@
 		writeback_inodes_sb_nr_if_idle(root->fs_info->sb, nr_pages);

 		spin_lock(&space_info->lock);
-		if (reserved > space_info->bytes_reserved)
+		if (reserved > space_info->bytes_reserved) {
+			loops = 0;
 			reclaimed += reserved - space_info->bytes_reserved;
+		} else {
+			loops++;
+		}
 		reserved = space_info->bytes_reserved;
 		spin_unlock(&space_info->lock);

@@ -3379,7 +3385,12 @@
 			return -EAGAIN;

 		__set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(pause);
+		time_left = schedule_timeout(pause);
+
+		/* We were interrupted, exit */
+		if (time_left)
+			break;
+
 		pause <<= 1;
 		if (pause > HZ / 10)
 			pause = HZ / 10;


add text -> time tests.

add text -> time tests.

--- test/unit/core/test-cast.c
+++ test/unit/core/test-cast.c
@@ -36,6 +36,7 @@
 void test_text_to_int64(void);
 void test_text_to_uint64(void);
 void test_text_to_float(void);
+void test_text_to_time(void);

 static grn_logger_info *logger;
 static grn_ctx context;
@@ -163,3 +164,15 @@
   cast_text("29.029");
   cut_assert_equal_double(29.029, 0.001, GRN_FLOAT_VALUE(&dest));
 }
+
+void
+test_text_to_time(void)
+{
+  long long int sec, usec;
+
+  grn_obj_reinit(&context, &dest, GRN_DB_TIME, 0);
+  cast_text("2009/11/24 05:52:10.02929");
+  GRN_TIME_UNPACK(GRN_TIME_VALUE(&dest), sec, usec);
+  cut_assert_equal_int(1259009530, sec);
+  cut_assert_equal_int(29290, usec);
+}


New info in beep() docstring.

New info in beep() docstring.

--- PC/winsound.c
+++ PC/winsound.c
@@ -49,7 +49,10 @@
 "\n"
 "The frequency argument specifies frequency, in hertz, of the sound.\n"
 "This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).\n"
-"The duration argument specifies the number of milli-seconds.\n";
+"The duration argument specifies the number of milli-seconds.\n"
+"Note:  Under Windows 95 and 98, the arguments are ignored; if the system\n"
+"has a sound card, the system default sound is played; else (no sound card)\n"
+"the standard system beep.\n";

 static char sound_module_doc[] =
 "PlaySound(sound, flags) - play a sound\n"


erts: Remove lock_check debug variables

erts: Remove lock_check debug variables

--- erts/emulator/beam/erl_process_lock.c
+++ erts/emulator/beam/erl_process_lock.c
@@ -669,7 +669,9 @@
 	      ErtsProcLocks b_need_locks)
 {
     Process *p1, *p2;
+#ifdef ERTS_ENABLE_LOCK_CHECK
     Eterm pid1, pid2;
+#endif
     erts_pix_lock_t *pix_lck1, *pix_lck2;
     ErtsProcLocks need_locks1, have_locks1, need_locks2, have_locks2;
     ErtsProcLocks unlock_mask;
@@ -684,24 +686,32 @@
     if (a_proc) {
 	if (a_proc->id < b_proc->id) {
 	    p1 = a_proc;
+#ifdef ERTS_ENABLE_LOCK_CHECK
 	    pid1 = a_proc->id;
+#endif
 	    pix_lck1 = a_pix_lck;
 	    need_locks1 = a_need_locks;
 	    have_locks1 = a_have_locks;
 	    p2 = b_proc;
+#ifdef ERTS_ENABLE_LOCK_CHECK
 	    pid2 = b_proc->id;
+#endif
 	    pix_lck2 = b_pix_lck;
 	    need_locks2 = b_need_locks;
 	    have_locks2 = b_have_locks;
 	}
 	else if (a_proc->id > b_proc->id) {
 	    p1 = b_proc;
+#ifdef ERTS_ENABLE_LOCK_CHECK
 	    pid1 = b_proc->id;
+#endif
 	    pix_lck1 = b_pix_lck;
 	    need_locks1 = b_need_locks;
 	    have_locks1 = b_have_locks;
 	    p2 = a_proc;
+#ifdef ERTS_ENABLE_LOCK_CHECK
 	    pid2 = a_proc->id;
+#endif
 	    pix_lck2 = a_pix_lck;
 	    need_locks2 = a_need_locks;
 	    have_locks2 = a_have_locks;
@@ -710,12 +720,16 @@
 	    ERTS_LC_ASSERT(a_proc == b_proc);
 	    ERTS_LC_ASSERT(a_proc->id == b_proc->id);
 	    p1 = a_proc;
+#ifdef ERTS_ENABLE_LOCK_CHECK
 	    pid1 = a_proc->id;
+#endif
 	    pix_lck1 = a_pix_lck;
 	    need_locks1 = a_need_locks | b_need_locks;
 	    have_locks1 = a_have_locks | b_have_locks;
 	    p2 = NULL;
+#ifdef ERTS_ENABLE_LOCK_CHECK
 	    pid2 = 0;
+#endif
 	    pix_lck2 = NULL;
 	    need_locks2 = 0;
 	    have_locks2 = 0;
@@ -723,12 +737,16 @@
     }
     else {
 	p1 = b_proc;
+#ifdef ERTS_ENABLE_LOCK_CHECK
 	pid1 = b_proc->id;
+#endif
 	pix_lck1 = b_pix_lck;
 	need_locks1 = b_need_locks;
 	have_locks1 = b_have_locks;
 	p2 = NULL;
+#ifdef ERTS_ENABLE_LOCK_CHECK
 	pid2 = 0;
+#endif
 	pix_lck2 = NULL;
 	need_locks2 = 0;
 	have_locks2 = 0;


Where is my code?

Where is my code?

--- src/client/q2pc_client.c
+++ src/client/q2pc_client.c
@@ -124,8 +124,6 @@
     i64 result = Q2PC_EAGAIN;
     while(result == Q2PC_EAGAIN){

-        ch_log_error("q28923q89213897123\n");
-
         result = conn.beg_read(&conn,&data, &len);
         if( result != Q2PC_EAGAIN) { ch_log_warn("Returning %i\n", result); }


Spoof PSN only if option enabled

Spoof PSN only if option enabled

--- plugin/user.c
+++ plugin/user.c
@@ -43,7 +43,7 @@
 static tai_hook_ref_t g_passphrase_decrypt_hook;
 static void passphrase_decrypt_patched(void *dat0, void *dat1, void *dat2, char *passphrase, int *result) {
   TAI_CONTINUE(void, g_passphrase_decrypt_hook, dat0, dat1, dat2, passphrase, result);
-  if (PSN_PASSPHRASE[0] != '\0' && *result == 1) {
+  if (config.use_psn_spoofing && PSN_PASSPHRASE[0] != '\0' && *result == 1) {
     sceClibMemcpy(passphrase, PSN_PASSPHRASE, sizeof(PSN_PASSPHRASE));
   }
 }


xfs: fix the comment of xfs_bmap_count_tree()

Signed-off-by: Zhi Yong Wu <271485df608e5866f00a6b53bd62a5efc2bd3593@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <f35e083611655abff224a5492605bc52368a36d2@sgi.com>
Signed-off-by: Ben Myers <46e490cac450e85a9cba3059365826296771cc03@sgi.com>

--- fs/xfs/xfs_bmap_util.c
+++ fs/xfs/xfs_bmap_util.c
@@ -357,7 +357,7 @@

 /*
  * Recursively walks each level of a btree
- * to count total fsblocks is use.
+ * to count total fsblocks in use.
  */
 STATIC int                                     /* error */
 xfs_bmap_count_tree(


usb_updater: add command to reset CR50 when updating over SPI

The new extension command is used to request device reset after a
successful update when communicating over SPI.

tpm_send_pkt() is being refactored to allow passing of different
extension commands.

BRANCH=none
BUG=chrome-os-partner:58226
TEST=verified that the system gets reset and the new image version
     kicks in on both gru (over SPI) and reef (over USB).

Change-Id: I02f3ef76fc4b4ee1e52dedb9cb538e072638257a
Signed-off-by: Vadim Bendebury <5515d6d2d0829cbe0dd0dcf2094aaded06d58514@google.com>
Reviewed-on: https://chromium-review.googlesource.com/395629
Commit-Ready: Vadim Bendebury <5515d6d2d0829cbe0dd0dcf2094aaded06d58514@chromium.org>
Tested-by: Vadim Bendebury <5515d6d2d0829cbe0dd0dcf2094aaded06d58514@chromium.org>
Reviewed-by: Bill Richardson <129945214b1d548d8e49b6c29c43094f8c78057f@chromium.org>

--- extra/usb_updater/usb_updater.c
+++ extra/usb_updater/usb_updater.c
@@ -155,8 +155,11 @@

 #define SIGNED_TRANSFER_SIZE 1024
 #define MAX_BUF_SIZE	(SIGNED_TRANSFER_SIZE + sizeof(struct upgrade_pkt))
+
+/* These are copied from ./include/extension.h */
 #define EXT_CMD		0xbaccd00a
 #define FW_UPGRADE	4
+#define POST_RESET	7

 struct usb_endpoint {
 	struct libusb_device_handle *devh;
@@ -208,7 +211,8 @@
 /* Prepare and transfer a block to /dev/tpm0, get a reply. */
 static int tpm_send_pkt(int fd, unsigned int digest, unsigned int addr,
 			const void *data, int size,
-			void *response, size_t *response_size)
+			void *response, size_t *response_size,
+			uint16_t subcmd)
 {
 	/* Used by transfer to /dev/tpm0 */
 	static uint8_t outbuf[MAX_BUF_SIZE];
@@ -225,7 +229,7 @@
 	out->tag = __cpu_to_be16(0x8001);
 	out->length = __cpu_to_be32(len);
 	out->ordinal = __cpu_to_be32(EXT_CMD);
-	out->subcmd = __cpu_to_be16(FW_UPGRADE);
+	out->subcmd = __cpu_to_be16(subcmd);
 	out->digest = digest;
 	out->address = __cpu_to_be32(addr);
 	memcpy(out->data, data, size);
@@ -661,7 +665,7 @@
 					 block_addr,
 					 data_ptr,
 					 payload_size, error_code,
-					 &rxed_size) < 0) {
+					 &rxed_size, FW_UPGRADE) < 0) {
 				fprintf(stderr,
 					"Failed to trasfer block, %zd to go\n",
 					data_len);
@@ -861,7 +865,7 @@
 	} else {
 		rxed_size = sizeof(start_resp);
 		if (tpm_send_pkt(td->tpm_fd, 0, 0, NULL, 0,
-				 &start_resp, &rxed_size) < 0) {
+				 &start_resp, &rxed_size, FW_UPGRADE) < 0) {
 			fprintf(stderr, "Failed to start transfer\n");
 			exit(update_error);
 		}
@@ -977,16 +981,25 @@
 		out = htobe32(UPGRADE_DONE);
 		xfer(&td->uep, &out, sizeof(out), &out,
 		     protocol_version < 3 ? sizeof(out) : 1);
-
-		printf("reboot\n");
-
 		/*
 		 * Send a second stop request, which should reboot without
 		 * replying.
 		 */
 		xfer(&td->uep, &out, sizeof(out), 0, 0);
-	}
-
+	} else {
+		uint8_t response;
+		size_t response_size;
+
+		/* Need to send extended command for posted reboot. */
+		if (tpm_send_pkt(td->tpm_fd, 0, 0, NULL, 0,
+				 &response, &response_size, POST_RESET) < 0) {
+			fprintf(stderr, "Failed to request posted reboot\n");
+			exit(update_error);
+		}
+
+	}
+
+	printf("Reboot request posted");
 	return num_txed_secitons;
 }


Resize when terminal is resized

Resize when terminal is resized

--- source/main.c
+++ source/main.c
@@ -1,5 +1,6 @@
 #include <ncurses.h>
 #include <stdbool.h>
+#include <signal.h>

 static bool Running = true;
 //static int Term_X = 0;
@@ -27,22 +28,33 @@
     delwin(p_win);
 }

+void update_screen(void) {
+    endwin();
+    /* Create the left and right windows */
+    WindowLeft  = create_window(0,0,LINES,COLS/2);
+    wprintw(WindowLeft,  "\rLeft");
+    wrefresh(WindowLeft);
+    WindowRight = create_window(COLS/2,0,LINES,COLS/2);
+    wprintw(WindowRight, "\rRight");
+    wrefresh(WindowRight);
+}
+
+void handle_signal(int sig) {
+    update_screen();
+    signal(SIGWINCH, handle_signal);
+}
+
 int main(int argc, char** argv) {
+    /* Handle terminal resizing */
+    signal(SIGWINCH, handle_signal);
     /* Initialize ncurses and user input settings */
     initscr();
     raw();
     keypad(stdscr, TRUE);
     noecho();
     refresh();
-    /* Create the left and right windows */
-    WindowLeft  = create_window(0,0,LINES,COLS/2);
-    WindowRight = create_window(COLS/2,0,LINES,COLS/2);
     while(Running) {
-        //getmaxyx(stdscr, Term_Y, Term_X);
-        wprintw(WindowLeft,  "\rLeft");
-        wprintw(WindowRight, "\rRight");
-        wrefresh(WindowLeft);
-        wrefresh(WindowRight);
+        update_screen();
         handle_input(getch());
     }
     destroy_window(WindowLeft);


tabs > spaces

tabs > spaces

Seriously, who uses spaces these days?!

Former-commit-id: 3202c1e3c912ef9aeb8efc125867f54cd0d36986

--- source/main.c
+++ source/main.c
@@ -56,7 +56,7 @@
 	audioLoad("romfs:/bgm/pamgaea.wav", &mainMenu, 5);
 	int channelBGM = 6; //Last channel + 1. Remember to update this!
 	int showGetBGM = 1; //Used to hide the get BGM info after a button press.
-    int showLoadLevels = 0; //Used to show option to load levels if external levels exist.
+	int showLoadLevels = 0; //Used to show option to load levels if external levels exist.
 	if(access(NAME_SDMC_PROJECT, 0) != -1) showLoadLevels = 1; //Set true if accessible at startup.
 	//Note: will still panic if file is ever removed during runtime when it needs it (by design?)

@@ -84,11 +84,11 @@
                 loaded = ROMFS;
 				break;
 			case ROMFS:;
-                fileData = fopen(NAME_SDMC_PROJECT, "rb");
-                if(!fileData) panic("NO EXTERNAL FILE TO LOAD!", "There was no external file to load. "
-                        "You need to put external levels in the location defined in the README", DEF_DEBUG, (int)fileData);
-                scorePath = NAME_SDMC_SCORE;
-                loaded = SDMC;
+				fileData = fopen(NAME_SDMC_PROJECT, "rb");
+				if(!fileData) panic("NO EXTERNAL FILE TO LOAD!", "There was no external file to load. "
+						"You need to put external levels in the location defined in the README", DEF_DEBUG, (int)fileData);
+				scorePath = NAME_SDMC_SCORE;
+				loaded = SDMC;
 				break;
 			}
 			data = getData(fileData);


store file list in memory; don't scroll past end

--- source/main.c
+++ source/main.c
@@ -10,22 +10,52 @@
 static WINDOW* WindowRight;

 static int Idx = 0; /* TODO: this should be per-window */
+//static char* Cwd = ""; /* TODO; this should be per-window */
+static char** Files; /* TODO: this should be per-window */
+static int FileCount; /* TODO: ditto */
+
+/* TODO redraw less frequently */
+/* TODO detect filesystem changes */
+
+/*TODO: when have collection of windows and ^^ vars are in a struct, should take a windex*/
+void get_files(){
+    /*free existing contents*/
+    int i=0;
+    if(Files){
+        /*fuck memory (this is broken)
+        while(Files[i]){
+            free(Files[i]);
+            i++;
+        }*/
+        free(Files);
+    }
+    /* TODO: malloc smartly, instead of tapping out at 1024 files */
+    Files = malloc(sizeof(char*)*1024);
+    Files[0] = ".."; /* parent directory; todo only add if cwd!=/ */
+    FILE* ls = popen("ls", "r");
+    size_t len = 0;
+    ssize_t read;
+    i=1;
+    while ((read = getline(&Files[i], &len, ls)) != -1){
+        i++;
+        if(i>1022) break;
+    }
+    FileCount=i-1;
+    Files[i]=0; /*always end with nullpointer */
+}

 void list_files(WINDOW* win) {
-    FILE* ls = popen("ls", "r");
-    char* filename = NULL;
-    size_t len = 0;
-    ssize_t read;
+    get_files();
     int topbuff=1; /* lines to skip before printing (window border/title) */
     int i = 0;
     int rows, cols;
     getmaxyx(win, rows, cols);
-    while ((read = getline(&filename, &len, ls)) != -1){
+    while (Files[i] != 0){
         if(i==Idx){
             wattron(win, A_STANDOUT);
             wattron(win, A_BOLD);
         }
-        mvwaddnstr(win, i+topbuff, 1, filename, cols-2); /* prevent spilling out of window with long filenames */
+        mvwaddnstr(win, i+topbuff, 1, Files[i], cols-2); /* prevent spilling out of window with long filenames */
         if(i==Idx){
             wattroff(win, A_STANDOUT);
             wattroff(win, A_BOLD);
@@ -33,13 +63,12 @@
         i++;
         if(i>rows) break; /* TODO: implement scrolling to handle when there are more files than lines */
     }
-    if(filename) free(filename);
 }

 void handle_input(char ch) {
     if(ch == 'q')
         Running = false;
-    if(ch == 'j')
+    if(ch == 'j' && Idx<FileCount)
         Idx+=1;
     if(ch == 'k' && Idx>0)
         Idx-=1;


cleaning up main.c, moving more configuration settings into the config.json

--- source/main.c
+++ source/main.c
@@ -37,6 +37,7 @@
 #define FILE_NAME_BUFFER_SIZE 255
 #define DATA_BUFFER_SIZE 128

+#define SENSOR_NODE_ADDRESS YOTTA_CFG_TELEMETRY_SENSOR_NODE_ADDRESS

 CSP_DEFINE_TASK(task_server) {

@@ -129,11 +130,9 @@

     struct usart_conf conf;
     /* set the device in KISS / UART interface */
-    //TODO: Set the UART in the config.json
-    char dev = (char)K_UART6;
+    char dev = (char)YOTTA_CFG_CSP_UART_BUS;
     conf.device = &dev;
-    //TODO: Set this in the config.json
-    conf.baudrate = 57600;
+    conf.baudrate = K_UART_CONSOLE_BAUDRATE;
     usart_init(&conf);

     /* init kiss interface */
@@ -147,7 +146,7 @@

     /* set to route through KISS / UART */
     csp_init(TELEMETRY_CSP_ADDRESS);
-    csp_route_set(YOTTA_CFG_TELEMETRY_SENSOR_NODE_ADDRESS, &csp_if_kiss, CSP_NODE_MAC);
+    csp_route_set(SENSOR_NODE_ADDRESS, &csp_if_kiss, CSP_NODE_MAC);
     csp_route_start_task(10000, 1);

     k_gpio_init(K_LED_GREEN, K_GPIO_OUTPUT, K_GPIO_PULL_NONE);


eventdev: use links map to unlink queues

The octeontx event device doesn't store the queues to port mapping as a
result it cannot return the exact number of queues unlinked from a port
when application wants to unlink all the queues mapped (supplies queues
param as NULL).

Using links_map we can determine the exact queues mapped to a specific
port and unlink them.

Signed-off-by: Pavan Nikhilesh <8184a94f8f7778086ea0697cdb513b2e42813b09@caviumnetworks.com>
Acked-by: Gage Eads <40e74f4682b7928915cbf15b25c304eff85f59a4@intel.com>


"fix style" (#12600)

"fix style" (#12600)

--- paddle/fluid/operators/elementwise_op_function.h
+++ paddle/fluid/operators/elementwise_op_function.h
@@ -534,8 +534,8 @@
                          const framework::Tensor& dout, int axis,
                          framework::Tensor* dx, framework::Tensor* dy,
                          DX_OP dx_op, DY_OP dy_op) {
-  const framework::DDim x_dim = x.dims();
-  const framework::DDim y_dim = y.dims();
+  const framework::DDim& x_dim = x.dims();
+  const framework::DDim& y_dim = y.dims();
   if (x.dims() == y.dims()) {
     ElemwiseGradComputeNoBroadcast<DeviceContext, T, DX_OP, DY_OP>(
         ctx, x_dim, y_dim, x, y, out, dout, axis, dx, dy, dx_op, dy_op);
@@ -558,19 +558,19 @@
                                  framework::Tensor* dx, framework::Tensor* dy,
                                  DX_OP dx_op, DY_OP dy_op) {
   if (dy == nullptr) {
-    const framework::DDim dx_dims = dout.dims();
+    const framework::DDim& dx_dims = dout.dims();
     auto dy_dims = dx_dims;
     ElemwiseGradComputeNoBroadcast<DeviceContext, T, DX_OP, DY_OP>(
         ctx, dx_dims, dy_dims, x, y, out, dout, axis, dx, dy, dx_op, dy_op);
   } else {
     if (dout.dims() == dy->dims()) {
-      const framework::DDim dx_dims = dout.dims();
-      const framework::DDim dy_dims = dy->dims();
+      const framework::DDim& dx_dims = dout.dims();
+      const framework::DDim& dy_dims = dy->dims();
       ElemwiseGradComputeNoBroadcast<DeviceContext, T, DX_OP, DY_OP>(
           ctx, dx_dims, dy_dims, x, y, out, dout, axis, dx, dy, dx_op, dy_op);
     } else {  // Y is a scalar
       auto dx_dims = dout.dims();
-      const framework::DDim dy_dims = dy->dims();
+      const framework::DDim& dy_dims = dy->dims();
       ElemwiseGradComputeWithBroadcast<DeviceContext, T, DX_OP, DY_OP>(
           ctx, dx_dims, dy_dims, x, y, out, dout, axis, dx, dy, dx_op, dy_op);
     }


update

update

--- spectrogram.c
+++ spectrogram.c
@@ -14,6 +14,9 @@
 #ifndef M_PI
 #    define M_PI 3.14159265358979323846
 #endif
+#ifndef M_E
+#    define M_E 2.7182818284590452354
+#endif

 struct sonicSpectrumStruct;
 typedef struct sonicSpectrumStruct *sonicSpectrum;
@@ -42,8 +45,6 @@
             spectrogram->allocatedSpectrums*sizeof(sonicSpectrum));
     }
     spectrogram->spectrums[spectrogram->numSpectrums++] = spectrum;
-    spectrogram->minPower = DBL_MAX;
-    spectrogram->maxPower = DBL_MIN;
     return spectrum;
 }

@@ -72,6 +73,8 @@
         sonicDestroySpectrogram(spectrogram);
         return NULL;
     }
+    spectrogram->minPower = DBL_MAX;
+    spectrogram->maxPower = DBL_MIN;
     return spectrogram;
 }

@@ -134,7 +137,7 @@
             sample1 = (total1 + (numChannels >> 1))/numChannels;
             sample2 = (total2 + (numChannels >> 1))/numChannels;
         }
-        ola_samples[i] = sinx*sample1 + (1.0 - sinx)*sample2;
+        ola_samples[i] = (1.0 - sinx)*sample1 + sinx*sample2;
     }
 }

@@ -152,15 +155,15 @@
     /* TODO: convert to fixed-point */
     double in[period];
     fftw_complex out[period/2 + 1];
-    spectrum->power = (double*)calloc(period/2, sizeof(double));
+    spectrum->numFreqs = period/2;
+    spectrum->power = (double*)calloc(spectrum->numFreqs, sizeof(double));
     computeOverlapAdd(samples, period, numChannels, in);
     fftw_plan p = fftw_plan_dft_r2c_1d(period, in, out, FFTW_ESTIMATE);
     fftw_execute(p);
     int i;
     /* Start at 1 to skip the DC power, which is just noise. */
     for(i = 1; i < period/2 + 1; ++i) {
-        double m = magnitude(out[i]);
-        double power = m*m;
+        double power = magnitude(out[i]);
         spectrum->power[i - 1] = power;
         if(power > spectrogram->maxPower) {
             spectrogram->maxPower = power;
@@ -219,19 +222,21 @@
     if(data == NULL) {
         return NULL;
     }
+    double minPower = spectrogram->minPower;
+    double maxPower = spectrogram->maxPower;
     int row, col;
     unsigned char *p = data;
     for(row = 0; row < numRows; row++) {
         for(col = 0; col < numCols; col++) {
             double power = interpolateSpectrogram(spectrogram, row, col, numRows, numCols);
-            double minPower = spectrogram->minPower;
-            double maxPower = spectrogram->maxPower;
             if(power < minPower && power > maxPower) {
                 fprintf(stderr, "Power outside min/max range\n");
                 exit(1);
             }
             double range = maxPower - minPower;
-            int value = (unsigned char)(((power - minPower)/range)*256);
+            /* Use log scale such that log(min) = 0, and log(max) = 255. */
+            int value = 256.0*sqrt(sqrt(log((M_E - 1.0)*(power - minPower)/range + 1.0)));
+            /* int value = (unsigned char)(((power - minPower)/range)*256); */
             if(value == 256) {
                 value = 255;
             }
@@ -254,7 +259,7 @@
     if(file == NULL) {
         return 0;
     }
-    if(fprintf(file, "P2\n# CREATOR: libsonic\n%d %d\n", bitmap->numCols, bitmap->numRows) < 0) {
+    if(fprintf(file, "P2\n# CREATOR: libsonic\n%d %d\n255\n", bitmap->numCols, bitmap->numRows) < 0) {
         fclose(file);
         return 0;
     }
@@ -262,7 +267,7 @@
     int numPixels = bitmap->numRows*bitmap->numCols;
     unsigned char *p = bitmap->data;
     for(i = 0; i < numPixels; i++) {
-        if(fprintf(file, "%d\n", *p++) < 0) {
+        if(fprintf(file, "%d\n", 255 - *p++) < 0) {
             fclose(file);
             return 0;
         }


Tiny clean up

Tiny clean up

--- spritetools.h
+++ spritetools.h
@@ -810,8 +810,7 @@

 //returns true if an entity is colliding with another entity
 bool st_entity_colliding_entity(st_ent ent0, st_ent ent1){
-	if(ent0.noCollide) return false;
-	if(ent1.noCollide) return false;
+	if(ent0.noCollide || ent1.noCollide) return false;
 	st_anim anim0 = st_entity_getanim(ent0);
 	st_anim anim1 = st_entity_getanim(ent1);
 	int left0 = ent0.xPos;


fdlink: add linux-specific includes

fdlink: add linux-specific includes

--- c_src/fdlink.c
+++ c_src/fdlink.c
@@ -1,4 +1,6 @@
 #include <sys/select.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <fcntl.h>


examples/ipsec-secgw: fix AES-CTR block size

This patch fixes the incorrect block size for AES-CTR in
legacy mode. Originally, wrong block size will cause
esp_inbound() drop AES-CTR encrypted packets if the payload
sizes not equal to multiple times of 16.

Fixes: 4470c22de2e1 ("examples/ipsec-secgw: add AES-CTR")
Cc: stable@dpdk.org

Signed-off-by: Fan Zhang <b46d470dc79aa6fd718cd24d07380f6203b7fc3c@intel.com>
Acked-by: Konstantin Ananyev <cbd5212b59ab42a210d72992d23a3aa17cfd3eaf@intel.com>
Acked-by: Akhil Goyal <74d7c4c993a22c1d4f60c46ff3d95c969a24a25c@nxp.com>

--- examples/ipsec-secgw/sa.c
+++ examples/ipsec-secgw/sa.c
@@ -80,7 +80,7 @@
 		.keyword = "aes-128-ctr",
 		.algo = RTE_CRYPTO_CIPHER_AES_CTR,
 		.iv_len = 8,
-		.block_size = 16, /* XXX AESNI MB limition, should be 4 */
+		.block_size = 4,
 		.key_len = 20
 	},
 	{


-- Enable a rewrite that was accidentally disabled.

--- pathfinder/compiler/algebra/opt/opt_join_graph.c
+++ pathfinder/compiler/algebra/opt/opt_join_graph.c
@@ -242,6 +242,7 @@
                 break;
             }
             break;
+#endif

         /* throw away proxy nodes and thus avoid calling option '-o {'
            which would remove all step_joins as well. */
@@ -249,7 +250,6 @@
         case la_proxy_base:
             *p = *PFla_dummy (L(p));
             break;
-#endif

         default:
             break;


Do not composite an app with its duplicate

--- libappstream-builder/plugins/asb-plugin-composite.c
+++ libappstream-builder/plugins/asb-plugin-composite.c
@@ -164,6 +164,11 @@
 			continue;
 		found = g_hash_table_lookup (hash, tmp);
 		if (found != NULL) {
+			/* ignore duplicates */
+			if (g_strcmp0 (as_app_get_id (app),
+				       as_app_get_id (found)) == 0) {
+				continue;
+			}
 			asb_plugin_composite_app (app, found);
 			continue;
 		}


하나의 process에서 singleton으로 동작함

하나의 process에서 singleton으로 동작함


Fixed accept hopefully.

Fixed accept hopefully.

--- psl1ght/libc-glue-ppu/source/socket.c
+++ psl1ght/libc-glue-ppu/source/socket.c
@@ -9,7 +9,10 @@
 #include <stdio.h>

 int accept(int socket, const struct sockaddr* address, socklen_t* address_len) {
-    return lv2Errno(lv2NetAccept(socket, address, (lv2_socklen_t *)address_len));
+    s32 ret = lv2NetAccept(socket, address, (lv2_socklen_t *)address_len);
+	if (ret < 0)
+		return lv2Errno(ret);
+	return ret;
 }

 int bind(int socket, const struct sockaddr* address, socklen_t address_len) {
@@ -54,7 +57,10 @@

 ssize_t recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)
 {
-	return 0;
+	s32 ret = lv2NetRecvFrom(s, buf, len, flags, from, fromlen);
+	if (ret < 0)
+		return lv2Errno(ret);
+	return ret;
 }

 int shutdown(int socket, int how)


Fixed print issue

Fixed print issue

--- Modules/Heap/heap.c
+++ Modules/Heap/heap.c
@@ -283,17 +283,31 @@
     #endif
   }

-  writeDebugStream("BCI HEAP DUMP:\n%d", bciHeap[loc]);
-
-  for (unsigned int i = loc + 1; i < loc + size; i++)
-  {
-    if (bciHeap[i] == BCI_FREE_FLAG)
-    {
-      writeDebugStream(",#");
+  writeDebugStream("BCI HEAP DUMP:\n");
+
+  for (unsigned int i = loc; i < loc + size; i++)
+  {
+    if (i == loc)
+    {
+      if (bciHeap[i] == BCI_FREE_FLAG)
+      {
+        writeDebugStream("#");
+      }
+      else
+      {
+        writeDebugStream("%d", bciHeap[i]);
+      }
     }
     else
     {
-      writeDebugStream(",%d", bciHeap[i]);
+      if (bciHeap[i] == BCI_FREE_FLAG)
+      {
+        writeDebugStream(",#");
+      }
+      else
+      {
+        writeDebugStream(",%d", bciHeap[i]);
+      }
     }
   }


plug leak and improve error handling in dbm_keys()

--- Modules/dbmmodule.c
+++ Modules/dbmmodule.c
@@ -168,6 +168,7 @@
 {
 	register object *v, *item;
 	datum key;
+	int err;

 	if (dp == NULL || !is_dbmobject(dp)) {
 		err_badcall();
@@ -179,11 +180,18 @@
 	if (v == NULL)
 		return NULL;
 	for (key = dbm_firstkey(dp->di_dbm); key.dptr;
-				key = dbm_nextkey(dp->di_dbm) ) {
-	    item = newsizedstringobject(key.dptr, key.dsize);
-	    if ( item == 0 )
-	      return NULL;
-	    addlistitem(v, item);
+	     key = dbm_nextkey(dp->di_dbm)) {
+		item = newsizedstringobject(key.dptr, key.dsize);
+		if (item == NULL) {
+			DECREF(v);
+			return NULL;
+		}
+		err = addlistitem(v, item);
+		DECREF(item);
+		if (err != 0) {
+			DECREF(v);
+			return NULL;
+		}
 	}
 	return v;
 }


tests: rename iopoll test variables

tests: rename iopoll test variables

Rename v1-v4 variables into something more descriptive, makes debugging
easier.

Signed-off-by: Pavel Begunkov <8608d41fe50396a9dbd36e830be65ba791e26c05@gmail.com>
Link: https://lore.kernel.org/r/66e749793b37a702c1ac37556c1e354e9dff3298.1629380408.git.8608d41fe50396a9dbd36e830be65ba791e26c05@gmail.com
Signed-off-by: Jens Axboe <cd8c6775e60d6f67a6984377324e5290df3d5358@kernel.dk>

--- test/iopoll.c
+++ test/iopoll.c
@@ -347,15 +347,15 @@
 	if (no_buf_select)
 		nr = 8;
 	for (i = 0; i < nr; i++) {
-		int v1, v2, v3, v4;
-
-		v1 = (i & 1) != 0;
-		v2 = (i & 2) != 0;
-		v3 = (i & 4) != 0;
-		v4 = (i & 8) != 0;
-		ret = test_io(fname, v1, v2, v3, v4);
-		if (ret) {
-			fprintf(stderr, "test_io failed %d/%d/%d/%d\n", v1, v2, v3, v4);
+		int write = (i & 1) != 0;
+		int sqthread = (i & 2) != 0;
+		int fixed = (i & 4) != 0;
+		int buf_select = (i & 8) != 0;
+
+		ret = test_io(fname, write, sqthread, fixed, buf_select);
+		if (ret) {
+			fprintf(stderr, "test_io failed %d/%d/%d/%d\n",
+				write, sqthread, fixed, buf_select);
 			goto err;
 		}
 		if (no_iopoll)


[DevTools] Add offset and scale to WebDeviceEmulationParams.

This will be used to set offset/scale from DevTools protocol
instead of caluculating them in embedder.

NOTRY=true

Review URL: https://codereview.chromium.org/342953003

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@176509 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- public/web/WebDeviceEmulationParams.h
+++ public/web/WebDeviceEmulationParams.h
@@ -5,6 +5,7 @@
 #ifndef WebDeviceEmulationParams_h
 #define WebDeviceEmulationParams_h

+#include "public/platform/WebFloatPoint.h"
 #include "public/platform/WebRect.h"
 #include "public/platform/WebSize.h"

@@ -33,10 +34,17 @@
     // Insets of emulated view inside available view space, in fit to view mode.
     WebSize viewInsets;

+    // Offset of emulated view inside available space, not in fit to view mode.
+    WebFloatPoint offset;
+
+    // Scale of emulated view inside available space, not in fit to view mode.
+    float scale;
+
     WebDeviceEmulationParams()
         : screenPosition(Desktop)
         , deviceScaleFactor(0)
-        , fitToView(false) { }
+        , fitToView(false)
+        , scale(1) { }
 };

 } // namespace blink


Update CompositeTensorBase to new static validParams member function

Refs #14135

--- framework/include/materials/CompositeTensorBase.h
+++ framework/include/materials/CompositeTensorBase.h
@@ -101,7 +101,7 @@
 InputParameters
 CompositeTensorBase<T, U>::validParams()
 {
-  InputParameters params = ::validParams<U>();
+  InputParameters params = U::validParams();
   params.addRequiredParam<std::vector<MaterialPropertyName>>("tensors", "Component tensors");
   params.addRequiredParam<std::vector<MaterialPropertyName>>("weights", "Component weights");
   params.addRequiredCoupledVar("args", "variable dependencies for the prefactor");


FUSB302:Implement decode SOP' and SOP'' enable function

Support for decode SOP' & and SOP'' enable function in the driver
to avoid system reboot when tcpm_sop_prime_enable() is called.
Refer to https://crrev.com/c/2381030 .

BRANCH=None
BUG=b:173081501
TEST=Connect Gatex to ADLP-RVP. No reboot and USB4 connection
is established.

Signed-off-by: Poornima Tom <33af2d34e25b2ae954dbdd64afa51fe7af7609b7@intel.com>
Change-Id: I418f7dfdf488289f27d7b0becf012f6cf554a025
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2517261
Reviewed-by: Keith Short <f6d578f97033c25f1206cb57d52f358974c82954@chromium.org>

--- driver/tcpm/fusb302.c
+++ driver/tcpm/fusb302.c
@@ -607,6 +607,24 @@
 	return 0;
 }

+__maybe_unused static int fusb302_tcpm_decode_sop_prime_enable(int port,
+								bool enable)
+{
+	int reg;
+
+	if (tcpc_read(port, TCPC_REG_CONTROL1, &reg))
+		return EC_ERROR_UNKNOWN;
+
+	if (enable)
+		reg |= (TCPC_REG_CONTROL1_ENSOP1 |
+				TCPC_REG_CONTROL1_ENSOP2);
+	else
+		reg &= ~(TCPC_REG_CONTROL1_ENSOP1 |
+			TCPC_REG_CONTROL1_ENSOP2);
+
+	return tcpc_write(port, TCPC_REG_CONTROL1, reg);
+}
+
 static int fusb302_tcpm_set_vconn(int port, int enable)
 {
 	/*
@@ -626,16 +644,13 @@
 		/* set to saved polarity */
 		tcpm_set_polarity(port, state[port].cc_polarity);

-#ifdef CONFIG_USB_PD_DECODE_SOP
-		if (state[port].rx_enable) {
-			if (tcpc_read(port, TCPC_REG_CONTROL1, &reg))
-				return EC_ERROR_UNKNOWN;
-
-			reg |= (TCPC_REG_CONTROL1_ENSOP1 |
-				TCPC_REG_CONTROL1_ENSOP2);
-			tcpc_write(port, TCPC_REG_CONTROL1, reg);
+		if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) {
+			if (state[port].rx_enable) {
+				if (fusb302_tcpm_decode_sop_prime_enable(port,
+									true))
+					return EC_ERROR_UNKNOWN;
+			}
 		}
-#endif
 	} else {

 		tcpc_read(port, TCPC_REG_SWITCHES0, &reg);
@@ -646,16 +661,13 @@

 		tcpc_write(port, TCPC_REG_SWITCHES0, reg);

-#ifdef CONFIG_USB_PD_DECODE_SOP
-		if (state[port].rx_enable) {
-			if (tcpc_read(port, TCPC_REG_CONTROL1, &reg))
-				return EC_ERROR_UNKNOWN;
-
-			reg &= ~(TCPC_REG_CONTROL1_ENSOP1 |
-				TCPC_REG_CONTROL1_ENSOP2);
-			tcpc_write(port, TCPC_REG_CONTROL1, reg);
+		if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) {
+			if (state[port].rx_enable) {
+				if (fusb302_tcpm_decode_sop_prime_enable(port,
+									false))
+					return EC_ERROR_UNKNOWN;
+			}
 		}
-#endif
 	}

 	return 0;
@@ -1177,6 +1189,9 @@
 	.select_rp_value	= &fusb302_tcpm_select_rp_value,
 	.set_cc			= &fusb302_tcpm_set_cc,
 	.set_polarity		= &fusb302_tcpm_set_polarity,
+#ifdef CONFIG_USB_PD_DECODE_SOP
+	.sop_prime_enable	= &fusb302_tcpm_decode_sop_prime_enable,
+#endif
 	.set_vconn		= &fusb302_tcpm_set_vconn,
 	.set_msg_header		= &fusb302_tcpm_set_msg_header,
 	.set_rx_enable		= &fusb302_tcpm_set_rx_enable,


Remove debug statement.

Remove debug statement.

--- dbd/db2/connection.c
+++ dbd/db2/connection.c
@@ -223,8 +223,6 @@
  * __gc
  */
 static int connection_gc(lua_State *L) {
-    printf("Freeing connection\n");
-
     /* always close the connection */
     connection_close(L);


ACPI: suppress compiler warnings in button.c

This patch fixes following compiler warnings when build via make W=1:

drivers/acpi/button.c:220:5: warning: no previous prototype for ‘acpi_lid_notifier_register’ [-Wmissing-prototypes]
drivers/acpi/button.c:226:5: warning: no previous prototype for ‘acpi_lid_notifier_unregister’ [-Wmissing-prototypes]
drivers/acpi/button.c:232:5: warning: no previous prototype for ‘acpi_lid_open’ [-Wmissing-prototypes]

Signed-off-by: Andy Shevchenko <74f0c009df510614346aa771cd21959b78cdb413@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <27ffc44a8ec6a212fba98cfc3246c6ce8ab131e0@intel.com>

--- drivers/acpi/button.c
+++ drivers/acpi/button.c
@@ -33,6 +33,7 @@
 #include <linux/slab.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
+#include <acpi/button.h>

 #define PREFIX "ACPI: "


kdump: add udev events for memory online/offline

Currently no udev events for memory hotplug "online" and "offline" are
generated:

  # udevadm monitor
  # echo offline > /sys/devices/system/memory/memory4/state
  ==> No event

When kdump is loaded, kexec detects the current memory configuration and
stores it in the pre-allocated ELF core header.  Therefore, for kdump it
is necessary to reload the kdump kernel with kexec when the memory
configuration changes (e.g.  for online/offline hotplug memory).

In order to do this automatically, udev rules should be used.  This kernel
patch adds udev events for "online" and "offline".  Together with this
kernel patch, the following udev rules for online/offline have to be added
to "/etc/udev/rules.d/98-kexec.rules":

  SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/etc/init.d/kdump restart"
  SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/etc/init.d/kdump restart"

[4bf0fb350827ce8d86875e76c923a478597c3cef@canb.auug.org.au: fixups for class to subsystem conversion]
Signed-off-by: Michael Holzheu <db4757c56f54651f568cc7cda79cd93c781b1605@linux.vnet.ibm.com>
Cc: Heiko Carstens <8dcf0f69152f32f23184f83357a3731522e56b9c@de.ibm.com>
Cc: Vivek Goyal <61d11262d0d9873ddb5a887f48fcb04e8c5973d0@redhat.com>
Cc: "Eric W. Biederman" <8a741aa8cbd77ebc4a56ddb528ce9fd15d42f034@xmission.com>
Cc: Kay Sievers <a591390dde1303c55d531fd687bfa5ffd43e435e@vrfy.org>
Cc: Dave Hansen <e169c2064f54e292652f83bb35eed10e1aa33f38@us.ibm.com>
Cc: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>
Cc: Greg KH <79e2475f81a6317276bf7cbb3958b20d289b78df@kroah.com>
Signed-off-by: Stephen Rothwell <4bf0fb350827ce8d86875e76c923a478597c3cef@canb.auug.org.au>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/base/memory.c
+++ drivers/base/memory.c
@@ -295,11 +295,22 @@

 	ret = memory_block_action(mem->start_section_nr, to_state);

-	if (ret)
+	if (ret) {
 		mem->state = from_state_req;
-	else
-		mem->state = to_state;
-
+		goto out;
+	}
+
+	mem->state = to_state;
+	switch (mem->state) {
+	case MEM_OFFLINE:
+		kobject_uevent(&mem->dev.kobj, KOBJ_OFFLINE);
+		break;
+	case MEM_ONLINE:
+		kobject_uevent(&mem->dev.kobj, KOBJ_ONLINE);
+		break;
+	default:
+		break;
+	}
 out:
 	mutex_unlock(&mem->state_mutex);
 	return ret;


tty: fix tty_line must not be equal to number of allocated tty pointers in tty driver

I found a bug "by chance" in drivers/char/tty_io.c

I mean "by chance" because I was just reading the code of the
tty_find_polling_driver() to make a new tty_find_by_name() function.

In tty_find_polling_driver() the driver actually test "tty_line <=
p->num" while num refers to the number of struct tty_struct pointers
allocated for the p->ttys (p is a tty_driver), and tty_line is scanned
in a tty name, which can be for example ttyS2. Then tty_line equals 2.
And if p->num is 2, we have only p->ttys[0] and p->ttys[1], but no
p->ttys[2].

This is actually unharmful, for tty_find_polling_driver() is used only
in drivers/serial/kgdboc.c, and there's a test over there to find a
console with a matching index, which will never happen.

This is still a bug anyway.

Signed-off-by: Nathael Pajani <2c8bc8024f2abdcf0bc468fedd7b3f759af968ef@ed3l.fr>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/char/tty_io.c
+++ drivers/char/tty_io.c
@@ -355,7 +355,7 @@
 		if (*stp == '\0')
 			stp = NULL;

-		if (tty_line >= 0 && tty_line <= p->num && p->ops &&
+		if (tty_line >= 0 && tty_line < p->num && p->ops &&
 		    p->ops->poll_init && !p->ops->poll_init(p, tty_line, stp)) {
 			res = tty_driver_kref_get(p);
 			*line = tty_line;


dmatest: fix use after free in dmatest_exit

dmatest_cleanup_chanel will free dtc, so grab ->chan before it goes away
and use it to do the release.

Reported-by: Thierry Reding <b75a4d02013b0e68ae2c6bb0dcfd4b7bec282dc9@avionic-design.de>
Signed-off-by: Dan Williams <24ee2bf0bd8ac766c348bf1f0639943bac1535c6@intel.com>

--- drivers/dma/dmatest.c
+++ drivers/dma/dmatest.c
@@ -430,13 +430,15 @@
 static void __exit dmatest_exit(void)
 {
 	struct dmatest_chan *dtc, *_dtc;
+	struct dma_chan *chan;

 	list_for_each_entry_safe(dtc, _dtc, &dmatest_channels, node) {
 		list_del(&dtc->node);
+		chan = dtc->chan;
 		dmatest_cleanup_channel(dtc);
 		pr_debug("dmatest: dropped channel %s\n",
-			 dma_chan_name(dtc->chan));
-		dma_release_channel(dtc->chan);
+			 dma_chan_name(chan));
+		dma_release_channel(chan);
 	}
 }
 module_exit(dmatest_exit);


dmaengine/dw_dmac: Divide one sg to many desc, if sg len is greater than DWC_MAX_COUNT

If len passed in sg for slave_sg transfers is greater than DWC_MAX_COUNT, then
driver programmes controller incorrectly.  This patch adds code to handle this
situation by allocation more than one desc for same sg.

Signed-off-by: Viresh Kumar <5ff32272b3d9f86512eddc8e0af523fc6f7924e5@st.com>
Signed-off-by: Vinod Koul <5cf69c63beb17bf38d63aa0e923ee8256af0e205@intel.com>

--- drivers/dma/dw_dmac.c
+++ drivers/dma/dw_dmac.c
@@ -693,9 +693,15 @@
 		reg = dws->tx_reg;
 		for_each_sg(sgl, sg, sg_len, i) {
 			struct dw_desc	*desc;
-			u32		len;
-			u32		mem;
-
+			u32		len, dlen, mem;
+
+			mem = sg_phys(sg);
+			len = sg_dma_len(sg);
+			mem_width = 2;
+			if (unlikely(mem & 3 || len & 3))
+				mem_width = 0;
+
+slave_sg_todev_fill_desc:
 			desc = dwc_desc_get(dwc);
 			if (!desc) {
 				dev_err(chan2dev(chan),
@@ -703,16 +709,19 @@
 				goto err_desc_get;
 			}

-			mem = sg_phys(sg);
-			len = sg_dma_len(sg);
-			mem_width = 2;
-			if (unlikely(mem & 3 || len & 3))
-				mem_width = 0;
-
 			desc->lli.sar = mem;
 			desc->lli.dar = reg;
 			desc->lli.ctllo = ctllo | DWC_CTLL_SRC_WIDTH(mem_width);
-			desc->lli.ctlhi = len >> mem_width;
+			if ((len >> mem_width) > DWC_MAX_COUNT) {
+				dlen = DWC_MAX_COUNT << mem_width;
+				mem += dlen;
+				len -= dlen;
+			} else {
+				dlen = len;
+				len = 0;
+			}
+
+			desc->lli.ctlhi = dlen >> mem_width;

 			if (!first) {
 				first = desc;
@@ -726,7 +735,10 @@
 						&first->tx_list);
 			}
 			prev = desc;
-			total_len += len;
+			total_len += dlen;
+
+			if (len)
+				goto slave_sg_todev_fill_desc;
 		}
 		break;
 	case DMA_FROM_DEVICE:
@@ -739,15 +751,7 @@
 		reg = dws->rx_reg;
 		for_each_sg(sgl, sg, sg_len, i) {
 			struct dw_desc	*desc;
-			u32		len;
-			u32		mem;
-
-			desc = dwc_desc_get(dwc);
-			if (!desc) {
-				dev_err(chan2dev(chan),
-					"not enough descriptors available\n");
-				goto err_desc_get;
-			}
+			u32		len, dlen, mem;

 			mem = sg_phys(sg);
 			len = sg_dma_len(sg);
@@ -755,10 +759,26 @@
 			if (unlikely(mem & 3 || len & 3))
 				mem_width = 0;

+slave_sg_fromdev_fill_desc:
+			desc = dwc_desc_get(dwc);
+			if (!desc) {
+				dev_err(chan2dev(chan),
+						"not enough descriptors available\n");
+				goto err_desc_get;
+			}
+
 			desc->lli.sar = reg;
 			desc->lli.dar = mem;
 			desc->lli.ctllo = ctllo | DWC_CTLL_DST_WIDTH(mem_width);
-			desc->lli.ctlhi = len >> reg_width;
+			if ((len >> reg_width) > DWC_MAX_COUNT) {
+				dlen = DWC_MAX_COUNT << reg_width;
+				mem += dlen;
+				len -= dlen;
+			} else {
+				dlen = len;
+				len = 0;
+			}
+			desc->lli.ctlhi = dlen >> reg_width;

 			if (!first) {
 				first = desc;
@@ -772,7 +792,10 @@
 						&first->tx_list);
 			}
 			prev = desc;
-			total_len += len;
+			total_len += dlen;
+
+			if (len)
+				goto slave_sg_fromdev_fill_desc;
 		}
 		break;
 	default:


i2c: use parent adapter quirks in mux

i2c: use parent adapter quirks in mux

Inherit parent adapter quirks in MUX in case the devices on the multiplexed
buses are interested in the adapter limitations.

Signed-off-by: Łukasz Gemborowski <a66c28eb73f6c8df4d322f4264228de655e61ba6@nokia.com>
Signed-off-by: Alexander Sverdlin <dace7423e438e9d50a283477134876fe17cd3341@nokia.com>
Signed-off-by: Wolfram Sang <fd4ce474653598159cad06f3c83387a05cd53a44@the-dreams.de>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@kernel.org
Fixes: b7f625840267b1 ("i2c: add quirk checks to core")

--- drivers/i2c/i2c-mux.c
+++ drivers/i2c/i2c-mux.c
@@ -144,6 +144,7 @@
 	priv->adap.dev.parent = &parent->dev;
 	priv->adap.retries = parent->retries;
 	priv->adap.timeout = parent->timeout;
+	priv->adap.quirks = parent->quirks;

 	/* Sanity check on class */
 	if (i2c_mux_parent_classes(parent) & class)


HACK: input: evdev: make CLOCK_MONOTONIC the default

Hack to maintain compatibility with existing Android userspace.

Change-Id: Ia6d768b3d51553bb43e7f70e605c2996a874e8cb
Signed-off-by: Colin Cross <380081620a7947c89c11153c5513f34019caa923@android.com>
[sboyd: touchscreen won't work without this patch]
Signed-off-by: Stephen Boyd <010521127f513270fe503d86ab8316ac5147f4b7@codeaurora.org>

--- drivers/input/evdev.c
+++ drivers/input/evdev.c
@@ -328,6 +328,7 @@
 	if (!client)
 		return -ENOMEM;

+	client->clkid = CLOCK_MONOTONIC;
 	client->bufsize = bufsize;
 	spin_lock_init(&client->buffer_lock);
 	snprintf(client->name, sizeof(client->name), "%s-%d",


Input: let driver core create class device attribute groups

Rely on device core to create attribute groups for input devices
instead of open-coding it.

Signed-off-by: Dmitry Torokhov <10a8c465cefc9bdd6c925e26964d23c90f1141cc@mail.ru>

--- drivers/input/input.c
+++ drivers/input/input.c
@@ -754,6 +754,13 @@
 	.attrs	= input_dev_caps_attrs,
 };

+static struct attribute_group *input_dev_attr_groups[] = {
+	&input_dev_attr_group,
+	&input_dev_id_attr_group,
+	&input_dev_caps_attr_group,
+	NULL
+};
+
 static void input_dev_release(struct class_device *class_dev)
 {
 	struct input_dev *dev = to_input_dev(class_dev);
@@ -907,6 +914,7 @@
 	dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
 	if (dev) {
 		dev->cdev.class = &input_class;
+		dev->cdev.groups = input_dev_attr_groups;
 		class_device_initialize(&dev->cdev);
 		mutex_init(&dev->mutex);
 		INIT_LIST_HEAD(&dev->h_list);
@@ -979,18 +987,6 @@
 	if (error)
 		return error;

-	error = sysfs_create_group(&dev->cdev.kobj, &input_dev_attr_group);
-	if (error)
-		goto fail1;
-
-	error = sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group);
-	if (error)
-		goto fail2;
-
-	error = sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
-	if (error)
-		goto fail3;
-
 	path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
 	printk(KERN_INFO "input: %s as %s\n",
 		dev->name ? dev->name : "Unspecified device", path ? path : "N/A");
@@ -1008,11 +1004,6 @@
 	input_wakeup_procfs_readers();

 	return 0;
-
- fail3:	sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
- fail2:	sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);
- fail1:	class_device_del(&dev->cdev);
-	return error;
 }
 EXPORT_SYMBOL(input_register_device);

@@ -1036,10 +1027,6 @@
 	}

 	list_del_init(&dev->node);
-
-	sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
-	sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
-	sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);

 	class_device_unregister(&dev->cdev);


changed ccl_pr_tree to print as a qpn query instead of some infix notation

--- ccl/cclptree.c
+++ ccl/cclptree.c
@@ -44,7 +44,7 @@
 /* CCL print rpn tree - infix notation
  * Europagate, 1995
  *
- * $Id: cclptree.c,v 1.9 2001-11-27 22:38:50 adam Exp $
+ * $Id: cclptree.c,v 1.10 2002-07-12 12:11:33 ja7 Exp $
  *
  * Old Europagate Log:
  *
@@ -73,56 +73,70 @@

 #include <yaz/ccl.h>

-void ccl_pr_tree (struct ccl_rpn_node *rpn, FILE *fd_out)
+void fprintSpaces(int indent,FILE * fd_out)
 {
+	char buf[100];
+	sprintf(buf,"%%%d.s",indent);
+	fprintf(fd_out,buf," ");
+};

+
+void ccl_pr_tree_as_qrpn(struct ccl_rpn_node *rpn, FILE *fd_out, int indent)
+{
+	if(indent>0) fprintSpaces(indent,fd_out);
     switch (rpn->kind)
     {
     case CCL_RPN_TERM:
-	fprintf (fd_out, "\"%s\"", rpn->u.t.term);
         if (rpn->u.t.attr_list)
         {
             struct ccl_rpn_attr *attr;
             for (attr = rpn->u.t.attr_list; attr; attr = attr->next)
                 if (attr->set)
-                    fprintf (fd_out, " %s,%d=%d", attr->set, attr->type,
+                    fprintf (fd_out, "@attr %s %d=%d ", attr->set, attr->type,
                              attr->value);
                 else
-                    fprintf (fd_out, " %d=%d", attr->type, attr->value);
+                    fprintf (fd_out, "@attr %d=%d ", attr->type, attr->value);
         }
+		fprintf (fd_out, "\"%s\"\n", rpn->u.t.term);
 	break;
     case CCL_RPN_AND:
-	fprintf (fd_out, "(");
-	ccl_pr_tree (rpn->u.p[0], fd_out);
-	fprintf (fd_out, ") and (");
-	ccl_pr_tree (rpn->u.p[1], fd_out);
-	fprintf (fd_out, ")");
+	fprintf (fd_out, "@and \n");
+	ccl_pr_tree_as_qrpn (rpn->u.p[0], fd_out,indent+2);
+	ccl_pr_tree_as_qrpn (rpn->u.p[1], fd_out,indent+2);
 	break;
     case CCL_RPN_OR:
-	fprintf (fd_out, "(");
-	ccl_pr_tree (rpn->u.p[0], fd_out);
-	fprintf (fd_out, ") or (");
-	ccl_pr_tree (rpn->u.p[1], fd_out);
-	fprintf (fd_out, ")");
+	fprintf (fd_out, "@or \n");
+	ccl_pr_tree_as_qrpn (rpn->u.p[0], fd_out,indent+2);
+	ccl_pr_tree_as_qrpn (rpn->u.p[1], fd_out,indent+2);
 	break;
     case CCL_RPN_NOT:
-	fprintf (fd_out, "(");
-	ccl_pr_tree (rpn->u.p[0], fd_out);
-	fprintf (fd_out, ") not (");
-	ccl_pr_tree (rpn->u.p[1], fd_out);
-	fprintf (fd_out, ")");
+	fprintf (fd_out, "@not ");
+	ccl_pr_tree_as_qrpn (rpn->u.p[0], fd_out,indent+2);
+	ccl_pr_tree_as_qrpn (rpn->u.p[1], fd_out,indent+2);
 	break;
     case CCL_RPN_SET:
-	fprintf (fd_out, "set=%s", rpn->u.setname);
+	fprintf (fd_out, "set=%s ", rpn->u.setname);
 	break;
     case CCL_RPN_PROX:
-	fprintf (fd_out, "(");
-	ccl_pr_tree (rpn->u.p[0], fd_out);
-	fprintf (fd_out, ") prox (");
-	ccl_pr_tree (rpn->u.p[1], fd_out);
-	fprintf (fd_out, ")");
+	fprintf (fd_out, "@prox ");
+	ccl_pr_tree_as_qrpn (rpn->u.p[0], fd_out,indent+2);
+	ccl_pr_tree_as_qrpn (rpn->u.p[1], fd_out,indent+2);
 	break;
     default:
-	ccl_assert (0);
+		fprintf(stderr,"Internal Error Unknown ccl_rpn node type %d\n",rpn->kind);
     }
 }
+
+
+void ccl_pr_tree (struct ccl_rpn_node *rpn, FILE *fd_out)
+{
+	ccl_pr_tree_as_qrpn(rpn,fd_out,0);
+}
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */


drivers: led: Fix device instance const qualifier loss in HT16K33

It is necessary to wrap the device pointer into data.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <ba81a3a719836727e6857ae83462b9f52ec41006@linux.intel.com>

--- drivers/led/ht16k33.c
+++ drivers/led/ht16k33.c
@@ -77,6 +77,7 @@

 struct ht16k33_data {
 	const struct device *i2c;
+	const struct device *dev;
 	struct led_data dev_data;
 	 /* Shadow buffer for the display data RAM */
 	uint8_t buffer[HT16K33_DISP_DATA_SIZE];
@@ -262,9 +263,8 @@
 	return pressed;
 }

-static void ht16k33_irq_thread(const struct device *dev)
-{
-	struct ht16k33_data *data = dev->data;
+static void ht16k33_irq_thread(struct ht16k33_data *data)
+{
 	bool pressed;

 	while (true) {
@@ -272,7 +272,7 @@

 		do {
 			k_sem_reset(&data->irq_sem);
-			pressed = ht16k33_process_keyscan_data(dev);
+			pressed = ht16k33_process_keyscan_data(data->dev);
 			k_msleep(CONFIG_HT16K33_KEYSCAN_DEBOUNCE_MSEC);
 		} while (pressed);
 	}
@@ -327,6 +327,8 @@
 	struct led_data *dev_data = &data->dev_data;
 	uint8_t cmd[1 + HT16K33_DISP_DATA_SIZE]; /* 1 byte command + data */
 	int err;
+
+	data->dev = dev;

 	data->i2c = device_get_binding(config->i2c_dev_name);
 	if (data->i2c == NULL) {
@@ -447,7 +449,7 @@

 	k_thread_create(&data->irq_thread, data->irq_thread_stack,
 			CONFIG_HT16K33_KEYSCAN_IRQ_THREAD_STACK_SIZE,
-			(k_thread_entry_t)ht16k33_irq_thread, dev, NULL, NULL,
+			(k_thread_entry_t)ht16k33_irq_thread, data, NULL, NULL,
 			K_PRIO_COOP(CONFIG_HT16K33_KEYSCAN_IRQ_THREAD_PRIO),
 			0, K_NO_WAIT);
 #endif /* CONFIG_HT16K33_KEYSCAN */


dm delay: support barriers

dm delay: support barriers

Flush support for dm-delay target.

Signed-off-by: Mikulas Patocka <52f8f9962b7f38d8269c63c0859d68147c8d10f0@redhat.com>
Signed-off-by: Alasdair G Kergon <620085386a2c64ec2f1d43bef997c15003f13da2@redhat.com>

--- drivers/md/dm-delay.c
+++ drivers/md/dm-delay.c
@@ -197,6 +197,7 @@
 	mutex_init(&dc->timer_lock);
 	atomic_set(&dc->may_delay, 1);

+	ti->num_flush_requests = 1;
 	ti->private = dc;
 	return 0;

@@ -278,8 +279,9 @@

 	if ((bio_data_dir(bio) == WRITE) && (dc->dev_write)) {
 		bio->bi_bdev = dc->dev_write->bdev;
-		bio->bi_sector = dc->start_write +
-				 (bio->bi_sector - ti->begin);
+		if (bio_sectors(bio))
+			bio->bi_sector = dc->start_write +
+					 (bio->bi_sector - ti->begin);

 		return delay_bio(dc, dc->write_delay, bio);
 	}