code cleanup

code cleanup

--- nc_perf/tst_gfs_data_1.c
+++ nc_perf/tst_gfs_data_1.c
@@ -52,38 +52,38 @@
 {
     FILE *fp;
     assert(filename && file_size);
-
+
     fp = fopen(filename, "r");
     if (fp)
     {
-	fseek(fp, 0 , SEEK_END);
-	*file_size = ftell(fp);
-	fclose(fp);
+        fseek(fp, 0 , SEEK_END);
+        *file_size = ftell(fp);
+        fclose(fp);
     }
     return 0;
 }

 /* Write all the metadata, including coordinate variable data. */
 int
-write_metadata(int ncid, int *data_varid, int s, int f, int deflate, int *dim_len, size_t phalf_loc_size, size_t phalf_start,
-	       float *value_phalf_loc, size_t *data_start, size_t *data_count, float *value_pfull_loc,
-	       size_t grid_xt_start, size_t grid_xt_loc_size, double *value_grid_xt_loc, size_t grid_yt_start,
-	       size_t grid_yt_loc_size, double *value_grid_yt_loc, size_t *latlon_start, size_t *latlon_count,
-	       double *value_lat_loc, double *value_lon_loc, int my_rank)
+write_meta(int ncid, int *data_varid, int s, int f, int deflate, int *dim_len, size_t phalf_loc_size, size_t phalf_start,
+           float *value_phalf_loc, size_t *data_start, size_t *data_count, float *value_pfull_loc,
+           size_t grid_xt_start, size_t grid_xt_loc_size, double *value_grid_xt_loc, size_t grid_yt_start,
+           size_t grid_yt_loc_size, double *value_grid_yt_loc, size_t *latlon_start, size_t *latlon_count,
+           double *value_lat_loc, double *value_lon_loc, int my_rank)
 {
     char dim_name[NDIM5][NC_MAX_NAME + 1] = {"grid_xt", "grid_yt", "pfull",
-					     "phalf", "time"};
+                                             "phalf", "time"};
     int dimid[NDIM5];
     int dimid_data[NDIM4];
     char var_name[NUM_META_VARS][NC_MAX_NAME + 1] = {"grid_xt", "lon", "grid_yt",
-						     "lat", "pfull", "phalf", "time"};
+                                                     "lat", "pfull", "phalf", "time"};
     int var_type[NUM_META_VARS] = {NC_DOUBLE, NC_DOUBLE, NC_DOUBLE, NC_DOUBLE,
-				   NC_FLOAT, NC_FLOAT, NC_DOUBLE};
+                                   NC_FLOAT, NC_FLOAT, NC_DOUBLE};
     int varid[NUM_META_VARS];
     double value_time = 2.0;
     int dv;
     int res;
-
+
     /* Turn off fill mode. */
     if (nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;

@@ -116,7 +116,7 @@
     if (nc_put_att_text(ncid, varid[3], "units", strlen("degrees_N"), "degrees_N")) ERR;

     if (nc_put_att_text(ncid, varid[2], "cartesian_axis", strlen("Y"), "Y")) ERR;
-
+
     /* Define dimension pfull. */
     if (nc_def_dim(ncid, dim_name[2], dim_len[2], &dimid[2])) ERR;

@@ -148,7 +148,7 @@

     /* In NOAA code, do all processors write the single time value? */
     if (my_rank == 0)
-	if (nc_put_var_double(ncid, varid[6], &value_time)) ERR;;
+        if (nc_put_var_double(ncid, varid[6], &value_time)) ERR;;
     if (nc_redef(ncid)) ERR;

     /* Write variable grid_xt data. */
@@ -179,50 +179,50 @@
     /* Define data variables. */
     for (dv = 0; dv < NUM_DATA_VARS; dv++)
     {
-	char data_var_name[NC_MAX_NAME + 1];
-
-	sprintf(data_var_name, "var_%d", dv);
-	if (nc_redef(ncid)) ERR;
-	if (nc_def_var(ncid, data_var_name, NC_FLOAT, NDIM4, dimid_data, &data_varid[dv])) ERR;
-
-	/* Setting any filter only will work for HDF5-1.10.3 and later */
-	/* versions. */
-	if (!f)
-	    res = nc_def_var_deflate(ncid, data_varid[dv], s, 1, deflate);
-	else
-	{
-	    res = nc_def_var_deflate(ncid, data_varid[dv], s, 0, 0);
-	    if (!res)
-		res = nc_def_var_szip(ncid, data_varid[dv], 32, 32);
-	}
+        char data_var_name[NC_MAX_NAME + 1];
+
+        sprintf(data_var_name, "var_%d", dv);
+        if (nc_redef(ncid)) ERR;
+        if (nc_def_var(ncid, data_var_name, NC_FLOAT, NDIM4, dimid_data, &data_varid[dv])) ERR;
+
+        /* Setting any filter only will work for HDF5-1.10.3 and later */
+        /* versions. */
+        if (!f)
+            res = nc_def_var_deflate(ncid, data_varid[dv], s, 1, deflate);
+        else
+        {
+            res = nc_def_var_deflate(ncid, data_varid[dv], s, 0, 0);
+            if (!res)
+                res = nc_def_var_szip(ncid, data_varid[dv], 32, 32);
+        }
 #ifdef HDF5_SUPPORTS_PAR_FILTERS
-	if (res) ERR;
+        if (res) ERR;
 #else
-	if (res != NC_EINVAL) ERR;
+        if (res != NC_EINVAL) ERR;
 #endif
-
-	if (nc_var_par_access(ncid, data_varid[dv], NC_COLLECTIVE)) ERR;
-	if (nc_enddef(ncid)) ERR;
+
+        if (nc_var_par_access(ncid, data_varid[dv], NC_COLLECTIVE)) ERR;
+        if (nc_enddef(ncid)) ERR;
     }

     if (nc_redef(ncid)) ERR;
     if (nc_put_att_text(ncid, varid[0], "long_name", strlen("T-cell longitude"), "T-cell longitude")) ERR;
     if (nc_put_att_text(ncid, varid[0], "units", strlen("degrees_E"), "degrees_E")) ERR;
-
+
     if (nc_put_att_text(ncid, varid[2], "long_name", strlen("T-cell latiitude"), "T-cell latiitude")) ERR;
     if (nc_put_att_text(ncid, varid[2], "units", strlen("degrees_N"), "degrees_N")) ERR;
     if (nc_enddef(ncid)) ERR;

     if (nc_redef(ncid)) ERR;
-
+
     for (dv = 0; dv < NUM_DATA_VARS; dv++)
     {
-	float compress_err = 42.22;
-	int nbits = 5;
-	if (nc_put_att_float(ncid, data_varid[dv], "max_abs_compression_error", NC_FLOAT, 1, &compress_err)) ERR;
-	if (nc_put_att_int(ncid, data_varid[dv], "nbits", NC_INT, 1, &nbits)) ERR;
-    }
-
+        float compress_err = 42.22;
+        int nbits = 5;
+        if (nc_put_att_float(ncid, data_varid[dv], "max_abs_compression_error", NC_FLOAT, 1, &compress_err)) ERR;
+        if (nc_put_att_int(ncid, data_varid[dv], "nbits", NC_INT, 1, &nbits)) ERR;
+    }
+
     if (nc_enddef(ncid)) ERR;
     return 0;
 }
@@ -231,7 +231,7 @@
  * decomposition of the 2D lat/lon coordinate variables. */
 int
 decomp_2D(int my_rank, int mpi_size, int *dim_len, size_t *latlon_start,
-	  size_t *latlon_count)
+          size_t *latlon_count)
 {

     /* Size of local arrays (i.e. for this pe) lon and lat data. This
@@ -239,70 +239,70 @@
     latlon_count[0] = dim_len[0]/2;
     if (my_rank == 0 || my_rank == 2)
     {
-	latlon_start[0] = 0;
+        latlon_start[0] = 0;
     }
     else
     {
-	latlon_start[0] = dim_len[0]/2;
+        latlon_start[0] = dim_len[0]/2;
     }
     latlon_count[1] = dim_len[1]/2;
     if (my_rank == 0 || my_rank == 1)
     {
-	latlon_start[1] = 0;
+        latlon_start[1] = 0;
     }
     else
     {
-	latlon_start[1] = dim_len[1]/2;
+        latlon_start[1] = dim_len[1]/2;
     }

     printf("%d: latlon_start %ld %ld latlon_count %ld %ld\n", my_rank, latlon_start[0],
-	   latlon_start[1], latlon_count[0], latlon_count[1]);
+           latlon_start[1], latlon_count[0], latlon_count[1]);

     return 0;
 }

-/* Based on the MPI rank and number of tasks, calculate the
+/* Based on the MPI rank and number of tasks, calculate the
  * decomposition of the 4D data. */
 int
 decomp_4D(int my_rank, int mpi_size, int *dim_len, size_t *start, size_t *count)
 {
     start[0] = 0;
     count[0] = 1;
-
+
     count[1] = dim_len[2]/mpi_size;
     start[1] = my_rank * count[1];
     /* Add any extra to the end. */
     if (my_rank == mpi_size - 1)
-	count[1] = count[1] + dim_len[2] % mpi_size;
+        count[1] = count[1] + dim_len[2] % mpi_size;

     if (mpi_size == 4)
     {
-	if (my_rank == 0 || my_rank == 1)
-	{
-	    start[2] = 0;
-	    start[3] = 0;
-	}
-	else
-	{
-	    start[2] = 768;
-	    start[3] = 768;
-	}
-	count[2] = 768;
-	count[3] = 1536;
+        if (my_rank == 0 || my_rank == 1)
+        {
+            start[2] = 0;
+            start[3] = 0;
+        }
+        else
+        {
+            start[2] = 768;
+            start[3] = 768;
+        }
+        count[2] = 768;
+        count[3] = 1536;
     }
     else if (mpi_size == 36)
     {
-	start[2] = my_rank * 256;
-	start[3] = my_rank * 512;
-	count[2] = 256;
-	count[3] = 512;
+        start[2] = my_rank * 256;
+        start[3] = my_rank * 512;
+        count[2] = 256;
+        count[3] = 512;
     }
     else
-	return ERR_AWFUL;
-
+        return ERR_AWFUL;
+
     printf("%d: start %ld %ld %ld %ld count %ld %ld %ld %ld\n", my_rank, start[0],
-    	   start[1], start[2], start[3], count[0], count[1], count[2], count[3]);
-
+           start[1], start[2], start[3], count[0], count[1], count[2], count[3]);
+
     return 0;
 }

@@ -317,25 +317,25 @@
     /* For timing. */
     double meta_start_time, meta_stop_time;
     double data_start_time, data_stop_time;
-
+
     int ncid;
     size_t latlon_start[NDIM2], latlon_count[NDIM2];
     size_t data_start[NDIM4], data_count[NDIM4];

     int dim_len[NDIM5] = {GRID_XT_LEN, GRID_YT_LEN, PFULL_LEN, PHALF_LEN,
-			  TIME_LEN};
+                          TIME_LEN};

     /* Variables. */
     int data_varid[NUM_DATA_VARS];
-    float *value_pfull_loc;
-    size_t phalf_loc_size, phalf_start;
-    float *value_phalf_loc;
-    size_t grid_xt_loc_size, grid_xt_start;
-    double *value_grid_xt_loc;
-    size_t grid_yt_loc_size, grid_yt_start;
-    double *value_grid_yt_loc;
-    double *value_lon_loc;
-    double *value_lat_loc;
+    float *pfull = NULL;
+    size_t phalf_size, phalf_start;
+    float *phalf = NULL;
+    size_t grid_xt_size, grid_xt_start;
+    double *grid_xt = NULL;
+    size_t grid_yt_size, grid_yt_start;
+    double *grid_yt = NULL;
+    double *lon = NULL;
+    double *lat = NULL;
     float *value_data;
     /* int deflate_level[NUM_DEFLATE_LEVELS] = {1, 4, 9}; */
     int deflate_level[NUM_DEFLATE_LEVELS] = {1};
@@ -355,58 +355,59 @@
     if (decomp_2D(my_rank, mpi_size, dim_len, latlon_start, latlon_count)) ERR;

     /* Size of local (i.e. for this pe) grid_xt data. */
-    grid_xt_loc_size = dim_len[0]/mpi_size;
-    grid_xt_start = my_rank * grid_xt_loc_size;
+    grid_xt_size = dim_len[0]/mpi_size;
+    grid_xt_start = my_rank * grid_xt_size;
     if (my_rank == mpi_size - 1)
-	grid_xt_loc_size = grid_xt_loc_size + dim_len[0] % mpi_size;
+        grid_xt_size = grid_xt_size + dim_len[0] % mpi_size;

     /* Size of local (i.e. for this pe) grid_yt data. */
-    grid_yt_loc_size = dim_len[1]/mpi_size;
-    grid_yt_start = my_rank * grid_yt_loc_size;
+    grid_yt_size = dim_len[1]/mpi_size;
+    grid_yt_start = my_rank * grid_yt_size;
     if (my_rank == mpi_size - 1)
-	grid_yt_loc_size = grid_yt_loc_size + dim_len[1] % mpi_size;
+        grid_yt_size = grid_yt_size + dim_len[1] % mpi_size;

     /* Size of local (i.e. for this pe) phalf data. */
-    phalf_loc_size = dim_len[3]/mpi_size;
-    phalf_start = my_rank * phalf_loc_size;
+    phalf_size = dim_len[3]/mpi_size;
+    phalf_start = my_rank * phalf_size;
     if (my_rank == mpi_size - 1)
-	phalf_loc_size = phalf_loc_size + dim_len[3] % mpi_size;
+        phalf_size = phalf_size + dim_len[3] % mpi_size;

     /* Allocate space on this pe to hold the coordinate var data for this pe. */
-    if (!(value_pfull_loc = malloc(data_count[1] * sizeof(float)))) ERR;
-    if (!(value_phalf_loc = malloc(phalf_loc_size * sizeof(float)))) ERR;
-    if (!(value_grid_xt_loc = malloc(grid_xt_loc_size * sizeof(double)))) ERR;
-    if (!(value_grid_yt_loc = malloc(grid_yt_loc_size * sizeof(double)))) ERR;
-    if (!(value_lon_loc = malloc(latlon_count[0] * latlon_count[1] * sizeof(double)))) ERR;
-    if (!(value_lat_loc = malloc(latlon_count[0] * latlon_count[1] * sizeof(double)))) ERR;
+    if (!(pfull = malloc(data_count[1] * sizeof(float)))) ERR;
+    if (!(phalf = malloc(phalf_size * sizeof(float)))) ERR;
+    if (!(grid_xt = malloc(grid_xt_size * sizeof(double)))) ERR;
+    if (!(grid_yt = malloc(grid_yt_size * sizeof(double)))) ERR;
+    if (!(lon = malloc(latlon_count[0] * latlon_count[1] * sizeof(double)))) ERR;
+    if (!(lat = malloc(latlon_count[0] * latlon_count[1] * sizeof(double)))) ERR;

     /* Allocate space to hold the data. */
     if (!(value_data = malloc(data_count[3] * data_count[2] * data_count[1] * sizeof(float)))) ERR;

     /* Some fake data for this pe to write. */
     for (i = 0; i < data_count[1]; i++)
-	value_pfull_loc[i] = my_rank * 100 + i;
-    for (i = 0; i < phalf_loc_size; i++)
-	value_phalf_loc[i] = my_rank * 100 + i;
-    for (i = 0; i < grid_xt_loc_size; i++)
-	value_grid_xt_loc[i] = my_rank * 100 + i;
-    for (i = 0; i < grid_yt_loc_size; i++)
-	value_grid_yt_loc[i] = my_rank * 100 + i;
+        pfull[i] = my_rank * 100 + i;
+    for (i = 0; i < phalf_size; i++)
+        phalf[i] = my_rank * 100 + i;
+    for (i = 0; i < grid_xt_size; i++)
+        grid_xt[i] = my_rank * 100 + i;
+    for (i = 0; i < grid_yt_size; i++)
+        grid_yt[i] = my_rank * 100 + i;
     for (j = 0; j < latlon_count[1]; j++)
     {
-	for(i = 0; i < latlon_count[0]; i++)
-	{
-	    value_lon_loc[j * latlon_count[0] + i] = my_rank * 100 + i + j;
-	    value_lat_loc[j * latlon_count[0] + i] = my_rank * 100 + i + j;
-	    for (k = 0; k < data_count[1]; k++)
-		value_data[j * latlon_count[0] + i] = my_rank * 100 + i + j + k;
-	}
+        for(i = 0; i < latlon_count[0]; i++)
+        {
+            lon[j * latlon_count[0] + i] = my_rank * 100 + i + j;
+            lat[j * latlon_count[0] + i] = my_rank * 100 + i + j;
+            for (k = 0; k < data_count[1]; k++)
+                value_data[j * latlon_count[0] + i] = my_rank * 100 + i + j + k;
+        }
     }

     if (my_rank == 0)
     {
-	printf("Benchmarking creation of UFS file.\n");
-	printf("comp, level, shuffle, meta wr time (s), data wr time (s), file size\n");
+        printf("Benchmarking creation of UFS file.\n");
+        printf("comp, level, shuffle, meta wr time (s), data wr time (s), "
+	       "file size\n");
     }
     {
         int s;
@@ -414,77 +415,91 @@
         {
             for (s = 0; s < NUM_SHUFFLE_SETTINGS; s++)
             {
-		for (dl = 0; dl < NUM_DEFLATE_LEVELS; dl++)
-		{
-		    size_t file_size;
-
-		    /* No deflate levels for szip. */
-		    if (f && dl) continue;
-
-		    /* nc_set_log_level(3); */
-		    /* Create a parallel netcdf-4 file. */
-		    meta_start_time = MPI_Wtime();
-		    if (nc_create_par(FILE_NAME, NC_NETCDF4, comm, info, &ncid)) ERR;
-
-		    if (write_metadata(ncid, data_varid, s, f, deflate_level[dl], dim_len, phalf_loc_size, phalf_start, value_phalf_loc, data_start, data_count, value_pfull_loc,
-				       grid_xt_start, grid_xt_loc_size, value_grid_xt_loc, grid_yt_start, grid_yt_loc_size, value_grid_yt_loc,
-				       latlon_start, latlon_count, value_lat_loc, value_lon_loc, my_rank)) ERR;
-
-
-		    MPI_Barrier(MPI_COMM_WORLD);
-		    meta_stop_time = MPI_Wtime();
-		    data_start_time = MPI_Wtime();
-
-		    /* Write one record each of the data variables. */
-		    for (dv = 0; dv < NUM_DATA_VARS; dv++)
-		    {
-			int r;
-			if ((r = nc_put_vara_float(ncid, data_varid[dv], data_start, data_count, value_data)))
-			{
-			    printf("%d: r %d f %d s %d dl %d\n", my_rank, r, f, s, dl);
-			    printf("%d: data_start %ld %ld %ld %ld data_count %ld %ld %ld %ld\n", my_rank, data_start[0], data_start[1],
-				   data_start[2], data_start[3], data_count[0], data_count[1], data_count[2], data_count[3]);
-			    ERR;
-			}
-			if (nc_redef(ncid)) ERR;
-		    }
-
-		    /* Close the file. */
-		    if (nc_close(ncid)) ERR;
-
-		    /* Stop the data timer. */
-		    MPI_Barrier(MPI_COMM_WORLD);
-		    data_stop_time = MPI_Wtime();
-
-		    /* Get the file size. */
-		    if (get_file_size(FILE_NAME, &file_size)) ERR;
-
-		    /* Print out results. */
-		    if (my_rank == 0)
-			printf("%s, %d, %d, %g, %g, %ld\n", (f ? "szip" : "zlib"), deflate_level[dl], s, meta_stop_time - meta_start_time,
-			       data_stop_time - data_start_time, file_size);
-		} /* next deflate level */
+                for (dl = 0; dl < NUM_DEFLATE_LEVELS; dl++)
+                {
+                    size_t file_size;
+
+                    /* No deflate levels for szip. */
+                    if (f && dl) continue;
+
+                    /* nc_set_log_level(3); */
+                    /* Create a parallel netcdf-4 file. */
+                    meta_start_time = MPI_Wtime();
+                    if (nc_create_par(FILE_NAME, NC_NETCDF4, comm, info,
+				      &ncid)) ERR;
+
+                    if (write_meta(ncid, data_varid, s, f, deflate_level[dl],
+                                   dim_len, phalf_size, phalf_start, phalf,
+				   data_start, data_count, pfull, grid_xt_start,
+				   grid_xt_size, grid_xt, grid_yt_start,
+				   grid_yt_size, grid_yt, latlon_start,
+				   latlon_count, lat, lon, my_rank)) ERR;
+
+		    /* Stop the timer for metadata writes. */
+                    MPI_Barrier(MPI_COMM_WORLD);
+                    meta_stop_time = MPI_Wtime();
+                    data_start_time = MPI_Wtime();
+
+                    /* Write one record each of the data variables. */
+                    for (dv = 0; dv < NUM_DATA_VARS; dv++)
+                    {
+                        int r;
+                        if ((r = nc_put_vara_float(ncid, data_varid[dv],
+						   data_start, data_count, value_data)))
+                        {
+                            printf("%d: r %d f %d s %d dl %d\n", my_rank, r, f, s, dl);
+                            printf("%d: data_start %ld %ld %ld %ld data_count %ld %ld %ld %ld\n",
+				   my_rank, data_start[0], data_start[1],
+                                   data_start[2], data_start[3], data_count[0],
+				   data_count[1], data_count[2], data_count[3]);
+                            ERR;
+                        }
+                        if (nc_redef(ncid)) ERR;
+                    }
+
+                    /* Close the file. */
+                    if (nc_close(ncid)) ERR;
+
+                    /* Stop the data timer. */
+                    MPI_Barrier(MPI_COMM_WORLD);
+                    data_stop_time = MPI_Wtime();
+
+                    /* Get the file size. */
+                    if (get_file_size(FILE_NAME, &file_size)) ERR;
+
+                    /* Print out results. */
+                    if (my_rank == 0)
+                        printf("%s, %d, %d, %g, %g, %ld\n", (f ? "szip" : "zlib"),
+			       deflate_level[dl], s, meta_stop_time - meta_start_time,
+                               data_stop_time - data_start_time, file_size);
+                } /* next deflate level */
             } /* next shuffle filter test */
         } /* next compression filter (zlib and szip) */

-	/* Free resources. */
-	free(value_grid_xt_loc);
-	free(value_grid_yt_loc);
-	free(value_pfull_loc);
-	free(value_phalf_loc);
-	free(value_lon_loc);
-	free(value_lat_loc);
-	free(value_data);
+        /* Free resources. */
+        if (grid_xt)
+            free(grid_xt);
+        if (grid_yt)
+            free(grid_yt);
+        if (pfull)
+            free(pfull);
+        if (phalf)
+            free(phalf);
+        if (lon)
+            free(lon);
+        if (lat)
+            free(lat);
+        free(value_data);
     }

     if (!my_rank)
         SUMMARIZE_ERR;
-
+
     /* Shut down MPI. */
     MPI_Finalize();

     if (!my_rank)
-    	FINAL_RESULTS;
+        FINAL_RESULTS;

     return 0;
 }


Small single app fix.

Small single app fix.

--- src/core/fusion/call.c
+++ src/core/fusion/call.c
@@ -239,7 +239,7 @@
      if (!call->handler)
           return FUSION_DESTROYED;

-     ret = call->handler( fusion_id, call_arg, call_ptr, call->ctx );
+     ret = call->handler( 1, call_arg, call_ptr, call->ctx );

      if (ret_val)
           *ret_val = ret;


Produce nicer warnings

Produce nicer warnings

--- src/core/iomgr/iomgr.c
+++ src/core/iomgr/iomgr.c
@@ -110,9 +110,14 @@

   gpr_mu_lock(&g_mu);
   g_shutdown = 1;
-  while (g_cbs_head || g_refs) {
-    gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed%s", g_refs,
-            g_cbs_head ? " and executing final callbacks" : "");
+  while (g_cbs_head != NULL || g_refs > 0) {
+    if (g_cbs_head != NULL && g_refs > 0) {
+      gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed and executing final callbacks", g_refs);
+    } else if (g_cbs_head != NULL) {
+      gpr_log(GPR_DEBUG, "Executing final iomgr callbacks");
+    } else {
+      gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed", g_refs);
+    }
     while (g_cbs_head) {
       cb = g_cbs_head;
       g_cbs_head = cb->next;


>  compile U201414800 sabertazimi Linux 17aa0d73d5e3 4.10.0-33-generic #37~16.04.1-Ubuntu SMP Fri Aug 11 14:07:24 UTC 2017 x86_64 GNU/Linux  03:42:17 up 18:54,  3 users,  load average: 0.22, 0.25, 0.23 cbfa7bed28fc5493ce32152bccdf87c69c219c51

--- nemu/src/memory/memory.c
+++ nemu/src/memory/memory.c
@@ -38,7 +38,7 @@
 #define PGADDR(d, t, o) ((uint32_t)((d) << PDXSHFT | (t) << PTXSHFT | (o)))

 // Address in page table or page directory entry
-#define PTE_ADDR(pte)   ((uint32_t)(pte) & ~0xfff)
+#define PTE_ADDR(pte)   ((uint32_t)(pte >> PTESHFT) & ~0xfffff)

 #define pmem_rw(addr, type) *(type *)({\
     Assert(addr < PMEM_SIZE, "physical address(0x%08x) is out of bound, EIP = 0x%08x", addr, cpu.eip); \


Copy the strings from ConfigurePrefs

Copy the strings from ConfigurePrefs

This also helps pass the "fixme" test.

--- src/configure.c
+++ src/configure.c
@@ -68,6 +68,9 @@
 	HostOS os;
 	HostKernel kernel;
 	Config * config;
+
+	/* prefs */
+	String * prefs_os;
 };

@@ -158,8 +161,22 @@
 	if((configure = object_new(sizeof(*configure))) == NULL)
 		return NULL;
 	if(prefs != NULL)
-		/* FIXME copy strings */
+	{
+		/* copy the strings */
+		if(prefs->os != NULL)
+		{
+			if((configure->prefs_os = string_new(prefs->os))
+					== NULL)
+			{
+				configure_delete(configure);
+				return NULL;
+			}
+		}
+		else
+			configure->prefs_os = NULL;
 		configure->prefs = *prefs;
+		configure->prefs.os = configure->prefs_os;
+	}
 	else
 		memset(&configure->prefs, 0, sizeof(configure->prefs));
 	_new_detect(configure);
@@ -280,6 +297,8 @@
 /* configure_delete */
 void configure_delete(Configure * configure)
 {
+	if(configure->prefs_os != NULL)
+		string_delete(configure->prefs_os);
 	if(configure->config != NULL)
 		config_delete(configure->config);
 	object_delete(configure);


Don't use 'inline'.

Don't use 'inline'.

'inline' is not a recognized C89 keyword, it made the build fail with strict or
older compilers (msvc 2008, gcc with -std=c89).

'inline' is also just a hint, one that gcc 4.4.3 in this particular case happily
ignored. Ergo, remove it.

--- http_parser.c
+++ http_parser.c
@@ -403,7 +403,7 @@
  * assumed that the caller cares about (and can detect) the transition between
  * URL and non-URL states by looking for these.
  */
-static inline enum state
+static enum state
 parse_url_char(enum state s, const char ch, int is_connect)
 {
   assert(!isspace(ch));


Bluetooth: Remove unused function

Bluetooth: Remove unused function

This patch removes hci_create_le_conn() since it is not used anymore.

Signed-off-by: Andre Guedes <282d5d3bbdb7014316a30ab22daf425f10cd096c@openbossa.org>
Signed-off-by: Marcel Holtmann <44592b4eea36663c86b994bb0ea99d15309c1c7d@holtmann.org>

--- net/bluetooth/hci_conn.c
+++ net/bluetooth/hci_conn.c
@@ -551,49 +551,6 @@
 	hci_dev_unlock(hdev);
 }

-static int hci_create_le_conn(struct hci_conn *conn)
-{
-	struct hci_dev *hdev = conn->hdev;
-	struct hci_cp_le_create_conn cp;
-	struct hci_request req;
-	u8 own_addr_type;
-	int err;
-
-	hci_req_init(&req, hdev);
-
-	memset(&cp, 0, sizeof(cp));
-
-	/* Update random address, but set require_privacy to false so
-	 * that we never connect with an unresolvable address.
-	 */
-	err = hci_update_random_address(&req, false, &own_addr_type);
-	if (err < 0)
-		return err;
-
-	conn->src_type = own_addr_type;
-
-	cp.scan_interval = cpu_to_le16(hdev->le_scan_interval);
-	cp.scan_window = cpu_to_le16(hdev->le_scan_window);
-	bacpy(&cp.peer_addr, &conn->dst);
-	cp.peer_addr_type = conn->dst_type;
-	cp.own_address_type = own_addr_type;
-	cp.conn_interval_min = cpu_to_le16(conn->le_conn_min_interval);
-	cp.conn_interval_max = cpu_to_le16(conn->le_conn_max_interval);
-	cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
-	cp.min_ce_len = __constant_cpu_to_le16(0x0000);
-	cp.max_ce_len = __constant_cpu_to_le16(0x0000);
-
-	hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
-
-	err = hci_req_run(&req, create_le_conn_complete);
-	if (err) {
-		hci_conn_del(conn);
-		return err;
-	}
-
-	return 0;
-}
-
 static void hci_req_add_le_create_conn(struct hci_request *req,
 				       struct hci_conn *conn)
 {


Bluetooth: Clear pending connections from hci_conn_params_clear

When hci_conn_params_clear is called, it is always followed by a
call to hci_pend_le_conns_clear. So instead of making this explicit
just make sure it is always called. This makes this function similar
on how hci_conn_params_add and hci_conn_params_del work.

Signed-off-by: Marcel Holtmann <44592b4eea36663c86b994bb0ea99d15309c1c7d@holtmann.org>
Signed-off-by: Johan Hedberg <628991c7b0a19c384f9b99c21ec330ce952bb838@intel.com>


Bluetooth: Initialize LE ACL MTU to proper value

Fix stack initialization.
When LE read buffer size returns 0 length LE buffers and controller
supports LE & BR/EDR functionality then ask controller about max ACL data
length it can accepts using BR/EDR read buffer size.
It should return value that can initialize LE MTU if that one still has 0.

Change-Id: Ib0bce89d47de5549d629a4ce771325e640443378
Signed-off-by: Arkadiusz Lichwa <a8f3d827a064762faaf15c916aaf7025632f7d7f@tieto.com>

--- net/bluetooth/hci_core.c
+++ net/bluetooth/hci_core.c
@@ -532,7 +532,7 @@
 	memcpy(dev.le_features, rp->features, sizeof(dev.le_features));
 }

-static void host_buffer_size_complete(struct bt_buf *buf)
+static void read_buffer_size_complete(struct bt_buf *buf)
 {
 	struct bt_hci_rp_read_buffer_size *rp = (void *)buf->data;

@@ -650,12 +650,10 @@
 				       sizeof(struct bt_hci_acl_hdr));
 	hbs->acl_pkts = sys_cpu_to_le16(ACL_IN_MAX);

-	err = bt_hci_cmd_send_sync(BT_HCI_OP_HOST_BUFFER_SIZE, buf, &rsp);
+	err = bt_hci_cmd_send(BT_HCI_OP_HOST_BUFFER_SIZE, buf);
 	if (err) {
 		return err;
 	}
-	host_buffer_size_complete(rsp);
-	bt_buf_put(rsp);

 	buf = bt_hci_cmd_create(BT_HCI_OP_SET_CTL_TO_HOST_FLOW, 1);
 	if (!buf) {
@@ -674,7 +672,12 @@

 		/* Use BR/EDR buffer size if LE reports zero buffers */
 		if (!dev.le_mtu) {
-			bt_hci_cmd_send(BT_HCI_OP_READ_BUFFER_SIZE, NULL);
+			err = bt_hci_cmd_send_sync(BT_HCI_OP_READ_BUFFER_SIZE, NULL, &rsp);
+			if (err) {
+				return err;
+			}
+			read_buffer_size_complete(rsp);
+			bt_buf_put(rsp);
 		}

 		buf = bt_hci_cmd_create(BT_HCI_OP_LE_WRITE_LE_HOST_SUPP,


Bluetooth: Fix keeping the command timer running

In the teardown path the reset command is sent to the controller,
this event causes the command timer to be reactivated.

So the timer is removed in two situations, when the adapter isn't
marked as UP and when we know that some command has been sent.

Reported-by: Keith Packard <fd7f967895e9f35e58ec8a62a847a54d7fa7275f@keithp.com>
Signed-off-by: Vinicius Costa Gomes <540a5b73c8ed8ee3381dfb54c1949e767fadd754@openbossa.org>
Signed-off-by: Gustavo F. Padovan <8463bae6aa74c6c37654a5ac7ce3bbb9fe6ffff8@profusion.mobi>

--- net/bluetooth/hci_core.c
+++ net/bluetooth/hci_core.c
@@ -587,10 +587,8 @@
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);

-	/* Stop timer, it might be running */
-	del_timer_sync(&hdev->cmd_timer);
-
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
+		del_timer_sync(&hdev->cmd_timer);
 		hci_req_unlock(hdev);
 		return 0;
 	}
@@ -629,6 +627,7 @@

 	/* Drop last sent command */
 	if (hdev->sent_cmd) {
+		del_timer_sync(&hdev->cmd_timer);
 		kfree_skb(hdev->sent_cmd);
 		hdev->sent_cmd = NULL;
 	}


Bluetooth: core: remove unrelated/inaccurate code comment

Change-Id: I41e312b28f8badf211cb9ded3015e7183d10154d
Signed-off-by: Johan Hedberg <628991c7b0a19c384f9b99c21ec330ce952bb838@intel.com>

--- net/bluetooth/hci_core.h
+++ net/bluetooth/hci_core.h
@@ -69,7 +69,6 @@
 	/* BR/EDR features page 0 */
 	uint8_t			features[8];

-	/* Current state of controller activity */
 	/* Supported commands */
 	uint8_t			supported_commands[36];


ASoC: omap: rx51: Add headset support

ASoC: omap: rx51: Add headset support

This patch adds support for headset microphone in Nokia RX-51/N900. The mic
signal from audio jack is routed to codec A LINE1L via two switches and the
mic bias is coming from codec B part.

First switch is the tv-out switch that is already supported and the second
switch selects between voltage detection circuit and codecs. As there is
no use for voltage detection at the moment the second switch is connected
statically to codecs in rx51_soc_init.

Headset can be active when control "Jack Function" is set to "Headset".

Signed-off-by: Jarkko Nikula <12ec1bb77030d67fad9a26e362b71e2dfbcda22a@gmail.com>
Acked-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <a57ef363056e61beffa2efa59c68550d40db03b0@slimlogic.co.uk>

--- sound/soc/omap/rx51.c
+++ sound/soc/omap/rx51.c
@@ -40,6 +40,7 @@

 #define RX51_TVOUT_SEL_GPIO		40
 #define RX51_JACK_DETECT_GPIO		177
+#define RX51_ECI_SW_GPIO		182
 /*
  * REVISIT: TWL4030 GPIO base in RX-51. Now statically defined to 192. This
  * gpio is reserved in arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -50,6 +51,7 @@
 	RX51_JACK_DISABLED,
 	RX51_JACK_TVOUT,		/* tv-out with stereo output */
 	RX51_JACK_HP,			/* headphone: stereo output, no mic */
+	RX51_JACK_HS,			/* headset: stereo output with mic */
 };

 static int rx51_spk_func;
@@ -59,11 +61,15 @@
 static void rx51_ext_control(struct snd_soc_codec *codec)
 {
 	struct snd_soc_dapm_context *dapm = &codec->dapm;
-	int hp = 0, tvout = 0;
+	int hp = 0, hs = 0, tvout = 0;

 	switch (rx51_jack_func) {
 	case RX51_JACK_TVOUT:
 		tvout = 1;
+		hp = 1;
+		break;
+	case RX51_JACK_HS:
+		hs = 1;
 	case RX51_JACK_HP:
 		hp = 1;
 		break;
@@ -81,6 +87,10 @@
 		snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
 	else
 		snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
+	if (hs)
+		snd_soc_dapm_enable_pin(dapm, "HS Mic");
+	else
+		snd_soc_dapm_disable_pin(dapm, "HS Mic");

 	gpio_set_value(RX51_TVOUT_SEL_GPIO, tvout);

@@ -240,6 +250,7 @@
 	SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event),
 	SND_SOC_DAPM_MIC("DMic", NULL),
 	SND_SOC_DAPM_HP("Headphone Jack", rx51_hp_event),
+	SND_SOC_DAPM_MIC("HS Mic", NULL),
 };

 static const struct snd_soc_dapm_widget aic34_dapm_widgetsb[] = {
@@ -259,11 +270,14 @@
 static const struct snd_soc_dapm_route audio_mapb[] = {
 	{"b LINE2R", NULL, "MONO_LOUT"},
 	{"Earphone", NULL, "b HPLOUT"},
+
+	{"LINE1L", NULL, "b Mic Bias 2.5V"},
+	{"b Mic Bias 2.5V", NULL, "HS Mic"}
 };

 static const char *spk_function[] = {"Off", "On"};
 static const char *input_function[] = {"ADC", "Digital Mic"};
-static const char *jack_function[] = {"Off", "TV-OUT", "Headphone"};
+static const char *jack_function[] = {"Off", "TV-OUT", "Headphone", "Headset"};

 static const struct soc_enum rx51_enum[] = {
 	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function),
@@ -398,6 +412,10 @@
 			       GPIOF_DIR_OUT | GPIOF_INIT_LOW, "tvout_sel");
 	if (err)
 		goto err_gpio_tvout_sel;
+	err = gpio_request_one(RX51_ECI_SW_GPIO,
+			       GPIOF_DIR_OUT | GPIOF_INIT_HIGH, "eci_sw");
+	if (err)
+		goto err_gpio_eci_sw;

 	rx51_snd_device = platform_device_alloc("soc-audio", -1);
 	if (!rx51_snd_device) {
@@ -415,6 +433,8 @@
 err2:
 	platform_device_put(rx51_snd_device);
 err1:
+	gpio_free(RX51_ECI_SW_GPIO);
+err_gpio_eci_sw:
 	gpio_free(RX51_TVOUT_SEL_GPIO);
 err_gpio_tvout_sel:

@@ -427,6 +447,7 @@
 				rx51_av_jack_gpios);

 	platform_device_unregister(rx51_snd_device);
+	gpio_free(RX51_ECI_SW_GPIO);
 	gpio_free(RX51_TVOUT_SEL_GPIO);
 }


net: fq_codel: Fix off-by-one error

net: fq_codel: Fix off-by-one error

Currently, we hold a max of sch->limit -1 number of packets instead of
sch->limit packets. Fix this off-by-one error.

Signed-off-by: Vijay Subramanian <217ddb6d937bb9e05e971478bf240274b34ab935@gmail.com>
Acked-by: Eric Dumazet <312c7d941f03386814be517ffdb3e0eb6624e275@google.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/sched/sch_fq_codel.c
+++ net/sched/sch_fq_codel.c
@@ -195,7 +195,7 @@
 		flow->deficit = q->quantum;
 		flow->dropped = 0;
 	}
-	if (++sch->q.qlen < sch->limit)
+	if (++sch->q.qlen <= sch->limit)
 		return NET_XMIT_SUCCESS;

 	q->drop_overlimit++;


ASoC: soc-cache: Block based rbtree compression

This patch prepares the ground for the actual rbtree optimization patch
which will save a pointer to the last accessed rbnode that was used
in either the read() or write() functions.

Each rbnode manages a variable length block of registers.  There can be no
two nodes with overlapping blocks.  Each block has a base register and a
currently top register, all the other registers, if any, lie in between these
two and in ascending order.

The reasoning behind the construction of this rbtree is simple.  In the
snd_soc_rbtree_cache_init() function, we iterate over the register defaults
provided by the driver.  For each register value that is non-zero we
insert it in the rbtree.  In order to determine in which rbnode we need
to add the register, we first look if there is another register already
added that is adjacent to the one we are about to add.  If that is the case
we append it in that rbnode block, otherwise we create a new rbnode
with a single register in its block and add it to the tree.

In the next patch, where a cached rbnode is used by both the write() and the
read() functions, we also check if the register we are about to add is in the
cached rbnode (the least recently accessed one) and if so we append it in that
rbnode block.

Signed-off-by: Dimitris Papastamos <a91262282f71bb8488398dcc9202f777d0206664@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <a57ef363056e61beffa2efa59c68550d40db03b0@ti.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>

--- sound/soc/soc-cache.c
+++ sound/soc/soc-cache.c
@@ -595,31 +595,85 @@
 }

 struct snd_soc_rbtree_node {
-	struct rb_node node;
-	unsigned int reg;
-	unsigned int value;
-	unsigned int defval;
+	struct rb_node node; /* the actual rbtree node holding this block */
+	unsigned int base_reg; /* base register handled by this block */
+	unsigned int word_size; /* number of bytes needed to represent the register index */
+	void *block; /* block of adjacent registers */
+	unsigned int blklen; /* number of registers available in the block */
 } __attribute__ ((packed));

 struct snd_soc_rbtree_ctx {
 	struct rb_root root;
 };

+static inline void snd_soc_rbtree_get_base_top_reg(
+	struct snd_soc_rbtree_node *rbnode,
+	unsigned int *base, unsigned int *top)
+{
+	*base = rbnode->base_reg;
+	*top = rbnode->base_reg + rbnode->blklen - 1;
+}
+
+static unsigned int snd_soc_rbtree_get_register(
+	struct snd_soc_rbtree_node *rbnode, unsigned int idx)
+{
+	unsigned int val;
+
+	switch (rbnode->word_size) {
+	case 1: {
+		u8 *p = rbnode->block;
+		val = p[idx];
+		return val;
+	}
+	case 2: {
+		u16 *p = rbnode->block;
+		val = p[idx];
+		return val;
+	}
+	default:
+		BUG();
+		break;
+	}
+	return -1;
+}
+
+static void snd_soc_rbtree_set_register(struct snd_soc_rbtree_node *rbnode,
+					unsigned int idx, unsigned int val)
+{
+	switch (rbnode->word_size) {
+	case 1: {
+		u8 *p = rbnode->block;
+		p[idx] = val;
+		break;
+	}
+	case 2: {
+		u16 *p = rbnode->block;
+		p[idx] = val;
+		break;
+	}
+	default:
+		BUG();
+		break;
+	}
+}
+
 static struct snd_soc_rbtree_node *snd_soc_rbtree_lookup(
 	struct rb_root *root, unsigned int reg)
 {
 	struct rb_node *node;
 	struct snd_soc_rbtree_node *rbnode;
+	unsigned int base_reg, top_reg;

 	node = root->rb_node;
 	while (node) {
 		rbnode = container_of(node, struct snd_soc_rbtree_node, node);
-		if (rbnode->reg < reg)
+		snd_soc_rbtree_get_base_top_reg(rbnode, &base_reg, &top_reg);
+		if (reg >= base_reg && reg <= top_reg)
+			return rbnode;
+		else if (reg > top_reg)
+			node = node->rb_right;
+		else if (reg < base_reg)
 			node = node->rb_left;
-		else if (rbnode->reg > reg)
-			node = node->rb_right;
-		else
-			return rbnode;
 	}

 	return NULL;
@@ -630,19 +684,28 @@
 {
 	struct rb_node **new, *parent;
 	struct snd_soc_rbtree_node *rbnode_tmp;
+	unsigned int base_reg_tmp, top_reg_tmp;
+	unsigned int base_reg;

 	parent = NULL;
 	new = &root->rb_node;
 	while (*new) {
 		rbnode_tmp = container_of(*new, struct snd_soc_rbtree_node,
 					  node);
+		/* base and top registers of the current rbnode */
+		snd_soc_rbtree_get_base_top_reg(rbnode_tmp, &base_reg_tmp,
+						&top_reg_tmp);
+		/* base register of the rbnode to be added */
+		base_reg = rbnode->base_reg;
 		parent = *new;
-		if (rbnode_tmp->reg < rbnode->reg)
+		/* if this register has already been inserted, just return */
+		if (base_reg >= base_reg_tmp &&
+		    base_reg <= top_reg_tmp)
+			return 0;
+		else if (base_reg > top_reg_tmp)
+			new = &((*new)->rb_right);
+		else if (base_reg < base_reg_tmp)
 			new = &((*new)->rb_left);
-		else if (rbnode_tmp->reg > rbnode->reg)
-			new = &((*new)->rb_right);
-		else
-			return 0;
 	}

 	/* insert the node into the rbtree */
@@ -657,28 +720,55 @@
 	struct snd_soc_rbtree_ctx *rbtree_ctx;
 	struct rb_node *node;
 	struct snd_soc_rbtree_node *rbnode;
+	unsigned int regtmp;
 	unsigned int val;
 	int ret;
+	int i;

 	rbtree_ctx = codec->reg_cache;
 	for (node = rb_first(&rbtree_ctx->root); node; node = rb_next(node)) {
 		rbnode = rb_entry(node, struct snd_soc_rbtree_node, node);
-		if (rbnode->value == rbnode->defval)
-			continue;
-		WARN_ON(codec->writable_register &&
-			codec->writable_register(codec, rbnode->reg));
-		ret = snd_soc_cache_read(codec, rbnode->reg, &val);
-		if (ret)
-			return ret;
-		codec->cache_bypass = 1;
-		ret = snd_soc_write(codec, rbnode->reg, val);
-		codec->cache_bypass = 0;
-		if (ret)
-			return ret;
-		dev_dbg(codec->dev, "Synced register %#x, value = %#x\n",
-			rbnode->reg, val);
-	}
-
+		for (i = 0; i < rbnode->blklen; ++i) {
+			regtmp = rbnode->base_reg + i;
+			WARN_ON(codec->writable_register &&
+				codec->writable_register(codec, regtmp));
+			val = snd_soc_rbtree_get_register(rbnode, i);
+			codec->cache_bypass = 1;
+			ret = snd_soc_write(codec, regtmp, val);
+			codec->cache_bypass = 0;
+			if (ret)
+				return ret;
+			dev_dbg(codec->dev, "Synced register %#x, value = %#x\n",
+				regtmp, val);
+		}
+	}
+
+	return 0;
+}
+
+static int snd_soc_rbtree_insert_to_block(struct snd_soc_rbtree_node *rbnode,
+					  unsigned int pos, unsigned int reg,
+					  unsigned int value)
+{
+	u8 *blk;
+
+	blk = krealloc(rbnode->block,
+		       (rbnode->blklen + 1) * rbnode->word_size, GFP_KERNEL);
+	if (!blk)
+		return -ENOMEM;
+
+	/* insert the register value in the correct place in the rbnode block */
+	memmove(blk + (pos + 1) * rbnode->word_size,
+		blk + pos * rbnode->word_size,
+		(rbnode->blklen - pos) * rbnode->word_size);
+
+	/* update the rbnode block, its size and the base register */
+	rbnode->block = blk;
+	rbnode->blklen++;
+	if (!pos)
+		rbnode->base_reg = reg;
+
+	snd_soc_rbtree_set_register(rbnode, pos, value);
 	return 0;
 }

@@ -686,28 +776,64 @@
 				      unsigned int reg, unsigned int value)
 {
 	struct snd_soc_rbtree_ctx *rbtree_ctx;
-	struct snd_soc_rbtree_node *rbnode;
+	struct snd_soc_rbtree_node *rbnode, *rbnode_tmp;
+	struct rb_node *node;
+	unsigned int val;
+	unsigned int reg_tmp;
+	unsigned int pos;
+	int i;
+	int ret;

 	rbtree_ctx = codec->reg_cache;
 	rbnode = snd_soc_rbtree_lookup(&rbtree_ctx->root, reg);
 	if (rbnode) {
-		if (rbnode->value == value)
+		reg_tmp = reg - rbnode->base_reg;
+		val = snd_soc_rbtree_get_register(rbnode, reg_tmp);
+		if (val == value)
 			return 0;
-		rbnode->value = value;
+		snd_soc_rbtree_set_register(rbnode, reg_tmp, value);
 	} else {
 		/* bail out early, no need to create the rbnode yet */
 		if (!value)
 			return 0;
-		/*
-		 * for uninitialized registers whose value is changed
-		 * from the default zero, create an rbnode and insert
-		 * it into the tree.
+		/* look for an adjacent register to the one we are about to add */
+		for (node = rb_first(&rbtree_ctx->root); node;
+		     node = rb_next(node)) {
+			rbnode_tmp = rb_entry(node, struct snd_soc_rbtree_node, node);
+			for (i = 0; i < rbnode_tmp->blklen; ++i) {
+				reg_tmp = rbnode_tmp->base_reg + i;
+				if (abs(reg_tmp - reg) != 1)
+					continue;
+				/* decide where in the block to place our register */
+				if (reg_tmp + 1 == reg)
+					pos = i + 1;
+				else
+					pos = i;
+				ret = snd_soc_rbtree_insert_to_block(rbnode_tmp, pos,
+								     reg, value);
+				if (ret)
+					return ret;
+				return 0;
+			}
+		}
+		/* we did not manage to find a place to insert it in an existing
+		 * block so create a new rbnode with a single register in its block.
+		 * This block will get populated further if any other adjacent
+		 * registers get modified in the future.
 		 */
 		rbnode = kzalloc(sizeof *rbnode, GFP_KERNEL);
 		if (!rbnode)
 			return -ENOMEM;
-		rbnode->reg = reg;
-		rbnode->value = value;
+		rbnode->blklen = 1;
+		rbnode->base_reg = reg;
+		rbnode->word_size = codec->driver->reg_word_size;
+		rbnode->block = kmalloc(rbnode->blklen * rbnode->word_size,
+					GFP_KERNEL);
+		if (!rbnode->block) {
+			kfree(rbnode);
+			return -ENOMEM;
+		}
+		snd_soc_rbtree_set_register(rbnode, 0, value);
 		snd_soc_rbtree_insert(&rbtree_ctx->root, rbnode);
 	}

@@ -719,11 +845,13 @@
 {
 	struct snd_soc_rbtree_ctx *rbtree_ctx;
 	struct snd_soc_rbtree_node *rbnode;
+	unsigned int reg_tmp;

 	rbtree_ctx = codec->reg_cache;
 	rbnode = snd_soc_rbtree_lookup(&rbtree_ctx->root, reg);
 	if (rbnode) {
-		*value = rbnode->value;
+		reg_tmp = reg - rbnode->base_reg;
+		*value = snd_soc_rbtree_get_register(rbnode, reg_tmp);
 	} else {
 		/* uninitialized registers default to 0 */
 		*value = 0;
@@ -749,6 +877,7 @@
 		rbtree_node = rb_entry(next, struct snd_soc_rbtree_node, node);
 		next = rb_next(&rbtree_node->node);
 		rb_erase(&rbtree_node->node, &rbtree_ctx->root);
+		kfree(rbtree_node->block);
 		kfree(rbtree_node);
 	}

@@ -761,10 +890,9 @@

 static int snd_soc_rbtree_cache_init(struct snd_soc_codec *codec)
 {
-	struct snd_soc_rbtree_node *rbtree_node;
 	struct snd_soc_rbtree_ctx *rbtree_ctx;
+	unsigned int word_size;
 	unsigned int val;
-	unsigned int word_size;
 	int i;
 	int ret;

@@ -778,28 +906,22 @@
 	if (!codec->reg_def_copy)
 		return 0;

-	/*
-	 * populate the rbtree with the initialized registers.  All other
-	 * registers will be inserted when they are first modified.
-	 */
 	word_size = codec->driver->reg_word_size;
 	for (i = 0; i < codec->driver->reg_cache_size; ++i) {
-		val = snd_soc_get_cache_val(codec->reg_def_copy, i, word_size);
+		val = snd_soc_get_cache_val(codec->reg_def_copy, i,
+					    word_size);
 		if (!val)
 			continue;
-		rbtree_node = kzalloc(sizeof *rbtree_node, GFP_KERNEL);
-		if (!rbtree_node) {
-			ret = -ENOMEM;
-			snd_soc_cache_exit(codec);
-			break;
-		}
-		rbtree_node->reg = i;
-		rbtree_node->value = val;
-		rbtree_node->defval = val;
-		snd_soc_rbtree_insert(&rbtree_ctx->root, rbtree_node);
-	}
-
-	return 0;
+		ret = snd_soc_rbtree_cache_write(codec, i, val);
+		if (ret)
+			goto err;
+	}
+
+	return 0;
+
+err:
+	snd_soc_cache_exit(codec);
+	return ret;
 }

 #ifdef CONFIG_SND_SOC_CACHE_LZO


corrected indentation

corrected indentation

git-svn-id: fbb392d5347ebc45c06187f72dfd8bab02595dbf@516382 13f79535-47bb-0310-9956-ffa450edef68

--- axiom/src/parser/guththila/guththila_xml_writer_wrapper.c
+++ axiom/src/parser/guththila/guththila_xml_writer_wrapper.c
@@ -24,85 +24,72 @@

 /************************ function prototypes ************************************/
 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_free(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_element(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_free(axiom_xml_writer_t *writer,
+    const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_start_element(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_end_start_element(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_element_with_namespace(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_end_start_element(axiom_xml_writer_t *writer,
+    const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_start_element_with_namespace(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *namespace_uri);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *namespace_uri,
     axis2_char_t *prefix);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_empty_element(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_empty_element(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_empty_element_with_namespace(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_empty_element_with_namespace(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *namespace_uri);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_empty_element_with_namespace_prefix(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_empty_element_with_namespace_prefix(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *namespace_uri,
     axis2_char_t *prefix);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_end_element(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_end_document(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_attribute(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env,
-	axis2_char_t *localname,
-	axis2_char_t *value);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_attribute_with_namespace(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_end_element(	axiom_xml_writer_t *writer,
+    const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_end_document(axiom_xml_writer_t *writer,
+    const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_attribute(axiom_xml_writer_t *writer,
+    const axis2_env_t *env,
+    axis2_char_t *localname,
+    axis2_char_t *value);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_attribute_with_namespace(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *value,
     axis2_char_t *namespace_uri);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_attribute_with_namespace_prefix(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_attribute_with_namespace_prefix(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *value,
@@ -110,120 +97,101 @@
     axis2_char_t *prefix);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_namespace(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_namespace(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *prefix,
     axis2_char_t *namespace_uri);

-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_default_namespace(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env,
-	axis2_char_t *namespace_uri);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_comment(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env,
-	axis2_char_t *value);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_processing_instruction(
-    axiom_xml_writer_t *writer,
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_default_namespace(axiom_xml_writer_t *writer,
+    const axis2_env_t *env,
+    axis2_char_t *namespace_uri);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_comment(axiom_xml_writer_t *writer,
+    const axis2_env_t *env,
+    axis2_char_t *value);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_processing_instruction(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *target);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_processing_instruction_data(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_processing_instruction_data(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *target,
     axis2_char_t *data);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_cdata(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env,
-	axis2_char_t *data);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_dtd(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env,
-	axis2_char_t *dtd);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_entity_ref(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_cdata(axiom_xml_writer_t *writer,
+    const axis2_env_t *env,
+    axis2_char_t *data);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_dtd(axiom_xml_writer_t *writer,
+    const axis2_env_t *env,
+    axis2_char_t *dtd);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_entity_ref(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *name);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_document(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_start_document(axiom_xml_writer_t *writer,
     const axis2_env_t *env);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_document_with_version(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_start_document_with_version(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *version);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_document_with_version_encoding(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_start_document_with_version_encoding(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *encoding,
     axis2_char_t *version);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_characters(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_characters(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *text);

 axis2_char_t* AXIS2_CALL
-guththila_xml_writer_wrapper_get_prefix(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env,
-	axis2_char_t *uri);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_set_prefix(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env,
-	axis2_char_t *prefix,
-	axis2_char_t *uri);
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_set_default_prefix(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_get_prefix(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *uri);

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_encoded(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_set_prefix(axiom_xml_writer_t *writer,
+    const axis2_env_t *env,
+    axis2_char_t *prefix,
+    axis2_char_t *uri);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_set_default_prefix(axiom_xml_writer_t *writer,
+    const axis2_env_t *env,
+    axis2_char_t *uri);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_encoded(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *text,
     int in_attr);

 void* AXIS2_CALL
-guththila_xml_writer_wrapper_get_xml(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env);
+guththila_xml_writer_wrapper_get_xml(axiom_xml_writer_t *writer,
+    const axis2_env_t *env);

 unsigned int AXIS2_CALL
-guththila_xml_writer_wrapper_get_xml_size(
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_raw (
-	axiom_xml_writer_t *writer,
-	const axis2_env_t *env,
-	axis2_char_t *content);
+guththila_xml_writer_wrapper_get_xml_size(axiom_xml_writer_t *writer,
+    const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_raw (axiom_xml_writer_t *writer,
+    const axis2_env_t *env,
+    axis2_char_t *content);

 /***************************** end function pointers *****************************/
@@ -242,12 +210,12 @@

 /******************************* End macro ***************************************/

-AXIS2_EXTERN axiom_xml_writer_t * AXIS2_CALL
+AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL
 axiom_xml_writer_create(const axis2_env_t *env,
-						axis2_char_t *filename,
-						axis2_char_t *encoding,
-						int is_prefix_default,
-						int compression)
+    axis2_char_t *filename,
+    axis2_char_t *encoding,
+    int is_prefix_default,
+    int compression)
 {
     guththila_xml_writer_wrapper_impl_t *writer_impl;

@@ -255,11 +223,10 @@
     AXIS2_ENV_CHECK(env, NULL);

     writer_impl = (guththila_xml_writer_wrapper_impl_t *)AXIS2_MALLOC(env->allocator,
-																	  sizeof(guththila_xml_writer_wrapper_impl_t));
+        sizeof(guththila_xml_writer_wrapper_impl_t));

     if (!writer_impl)
     {
-
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
@@ -276,8 +243,8 @@
     }

     guththila_create_xml_stream_writer((axis2_env_t*) env,
-									   writer_impl->parser,
-									   filename);
+        writer_impl->parser,
+        filename);

     if (!(writer_impl->parser->xsw))
     {
@@ -290,7 +257,7 @@

     writer_impl->writer.ops = NULL;
     writer_impl->writer.ops = (axiom_xml_writer_ops_t*)AXIS2_MALLOC(env->allocator,
-																	sizeof(axiom_xml_writer_ops_t));
+sizeof(axiom_xml_writer_ops_t));
     if (!(writer_impl->writer.ops))
     {
         AXIS2_FREE(env->allocator, writer_impl);
@@ -301,13 +268,15 @@
     }
     /* ops */
     writer_impl->writer.ops->free = guththila_xml_writer_wrapper_free;
-    writer_impl->writer.ops->write_start_element = guththila_xml_writer_wrapper_write_start_element;
+    writer_impl->writer.ops->write_start_element =
+        guththila_xml_writer_wrapper_write_start_element;
     writer_impl->writer.ops->write_start_element_with_namespace =
         guththila_xml_writer_wrapper_write_start_element_with_namespace;
     writer_impl->writer.ops->write_start_element_with_namespace_prefix =
         guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix;

-    writer_impl->writer.ops->write_empty_element = guththila_xml_writer_wrapper_write_empty_element;
+    writer_impl->writer.ops->write_empty_element =
+        guththila_xml_writer_wrapper_write_empty_element;
     writer_impl->writer.ops->write_empty_element_with_namespace  =
         guththila_xml_writer_wrapper_write_empty_element_with_namespace;
     writer_impl->writer.ops->write_empty_element_with_namespace_prefix =
@@ -365,23 +334,22 @@
     return &(writer_impl->writer);
 }

-AXIS2_EXTERN axiom_xml_writer_t * AXIS2_CALL
+AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL
 axiom_xml_writer_create_for_memory(const axis2_env_t *env,
-								   axis2_char_t *encoding,
-								   int is_prefix_default,
-								   int compression,
-								   int type)
+    axis2_char_t *encoding,
+    int is_prefix_default,
+    int compression,
+    int type)
 {
     guththila_xml_writer_wrapper_impl_t *writer_impl = NULL;

     AXIS2_ENV_CHECK(env, NULL);

     writer_impl = (guththila_xml_writer_wrapper_impl_t *)AXIS2_MALLOC(env->allocator,
-																	  sizeof(guththila_xml_writer_wrapper_impl_t));
+        sizeof(guththila_xml_writer_wrapper_impl_t));

     if (!writer_impl)
     {
-
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
@@ -392,43 +360,41 @@
     if (!(writer_impl->parser))
     {
         AXIS2_FREE(env->allocator, writer_impl);
-/*         AXIS2_FREE(env->allocator, allocator); */
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
     /* guththila xml stream writer for memory */
     guththila_create_xml_stream_writer_for_memory((axis2_env_t*) env,
-												  writer_impl->parser);
+        writer_impl->parser);

     if (!(writer_impl->parser->xsw))
     {
         AXIS2_FREE(env->allocator, writer_impl->parser);
         AXIS2_FREE(env->allocator, writer_impl);
-/*         AXIS2_FREE(env->allocator, allocator); */
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }

     writer_impl->writer.ops = NULL;
     writer_impl->writer.ops = (axiom_xml_writer_ops_t*)AXIS2_MALLOC(env->allocator,
-																	sizeof(axiom_xml_writer_ops_t));
+        sizeof(axiom_xml_writer_ops_t));
     if (!(writer_impl->writer.ops))
     {
         AXIS2_FREE(env->allocator, writer_impl);
-/*         AXIS2_FREE(env->allocator, allocator); */
-
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
     /* ops */
     writer_impl->writer.ops->free = guththila_xml_writer_wrapper_free;
-    writer_impl->writer.ops->write_start_element = guththila_xml_writer_wrapper_write_start_element;
+    writer_impl->writer.ops->write_start_element =
+        guththila_xml_writer_wrapper_write_start_element;
     writer_impl->writer.ops->write_start_element_with_namespace =
         guththila_xml_writer_wrapper_write_start_element_with_namespace;
     writer_impl->writer.ops->write_start_element_with_namespace_prefix =
         guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix;

-    writer_impl->writer.ops->write_empty_element = guththila_xml_writer_wrapper_write_empty_element;
+    writer_impl->writer.ops->write_empty_element =
+        guththila_xml_writer_wrapper_write_empty_element;
     writer_impl->writer.ops->write_empty_element_with_namespace  =
         guththila_xml_writer_wrapper_write_empty_element_with_namespace;
     writer_impl->writer.ops->write_empty_element_with_namespace_prefix =
@@ -489,47 +455,48 @@

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_free(axiom_xml_writer_t *writer,
-								  const axis2_env_t *env)
+    const axis2_env_t *env)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     if (AXIS2_INTF_TO_IMPL(writer)->parser)
     {
         if (AXIS2_INTF_TO_IMPL(writer)->parser->xsw)
+        {
             guththila_xml_writer_free((axis2_env_t *)env,
-									  AXIS2_INTF_TO_IMPL(writer)->parser);
-
-        guththila_free((axis2_env_t *)env,
-					   AXIS2_INTF_TO_IMPL(writer)->parser);
+                AXIS2_INTF_TO_IMPL(writer)->parser);
+        }
+        guththila_free((axis2_env_t *)env, AXIS2_INTF_TO_IMPL(writer)->parser);
     }

     if (writer->ops)
+    {
         AXIS2_FREE(env->allocator, writer->ops);
+    }

     if (writer)
+    {
         AXIS2_FREE(env->allocator, AXIS2_INTF_TO_IMPL(writer));
-
-    return AXIS2_SUCCESS;
-}
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_element(
-    axiom_xml_writer_t *writer,
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_start_element(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname)
 {
     int status = AXIS2_SUCCESS;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
-    guththila_write_start_element(
-        (axis2_env_t *)env,
+    guththila_write_start_element((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         localname);
     return status;
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_element_with_namespace(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_start_element_with_namespace(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *namespace_uri)
@@ -538,8 +505,7 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE);
-    guththila_write_start_element_with_namespace(
-        (axis2_env_t *)env,
+    guththila_write_start_element_with_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         localname,
         namespace_uri);
@@ -547,8 +513,7 @@
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *namespace_uri,
@@ -558,8 +523,7 @@
     AXIS2_PARAM_CHECK(env->error, localname,  AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE);
-    guththila_write_start_element_with_prefix_and_namespace(
-        (axis2_env_t *)env,
+    guththila_write_start_element_with_prefix_and_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         prefix, namespace_uri, localname);
     return AXIS2_SUCCESS;
@@ -567,24 +531,19 @@
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_empty_element(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_empty_element(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
-    guththila_write_empty_element(
-        (axis2_env_t *)env,
+    guththila_write_empty_element((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser, localname);
     return AXIS2_SUCCESS;
-
-
-}
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_empty_element_with_namespace(
-    axiom_xml_writer_t *writer,
+}
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_empty_element_with_namespace(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *namespace_uri)
@@ -592,16 +551,14 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE);
-    guththila_write_empty_element_with_namespace(
-        (axis2_env_t *)env,
+    guththila_write_empty_element_with_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         namespace_uri, localname);
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_empty_element_with_namespace_prefix(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_empty_element_with_namespace_prefix(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *namespace_uri,
@@ -612,33 +569,28 @@
     AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE);

-    guththila_write_empty_element_with_prefix_and_namespace(
-        (axis2_env_t *)env,
+    guththila_write_empty_element_with_prefix_and_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         prefix, namespace_uri, localname);
     return AXIS2_SUCCESS;
-
-
 }

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_end_element(axiom_xml_writer_t *writer,
-											   const axis2_env_t *env)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    guththila_write_end_element(
-        (axis2_env_t *)env,
+    const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    guththila_write_end_element((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser);
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_end_document(axiom_xml_writer_t *writer,
-												const axis2_env_t *env)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    guththila_write_end_document(
-        (axis2_env_t *)env,
+    const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    guththila_write_end_document((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser);
     return AXIS2_SUCCESS;

@@ -646,26 +598,21 @@

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_attribute(axiom_xml_writer_t *writer,
-											 const axis2_env_t *env,
-											 axis2_char_t *localname,
-											 axis2_char_t *value)
+    const axis2_env_t *env,
+    axis2_char_t *localname,
+    axis2_char_t *value)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);
-    guththila_write_attribute(
-        (axis2_env_t *)env,
+    guththila_write_attribute((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         localname, value);
     return AXIS2_SUCCESS;
-
-
-
-}
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_attribute_with_namespace(
-    axiom_xml_writer_t *writer,
+}
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_attribute_with_namespace(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *value,
@@ -676,16 +623,14 @@
     AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE);

-    guththila_write_attribute_with_namespace(
-        (axis2_env_t *)env,
+    guththila_write_attribute_with_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         namespace_uri, localname, value);
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_attribute_with_namespace_prefix(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_attribute_with_namespace_prefix(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *localname,
     axis2_char_t *value,
@@ -697,85 +642,65 @@
     AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, prefix , AXIS2_FAILURE);
-    guththila_write_attribute_with_prefix_and_namespace(
-        (axis2_env_t *)env,
+    guththila_write_attribute_with_prefix_and_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         prefix, namespace_uri, localname, value);
     return AXIS2_SUCCESS;
-
-
-
 }

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_namespace(axiom_xml_writer_t *writer,
-											 const axis2_env_t *env,
-											 axis2_char_t *prefix,
-											 axis2_char_t *namespace_uri)
+    const axis2_env_t *env,
+    axis2_char_t *prefix,
+    axis2_char_t *namespace_uri)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE);
-    /*     AXIS2_PARAM_CHECK(env->error, prefix , AXIS2_FAILURE); */
     /* when defult namespace comes prefix is null */
-    guththila_write_namespace(
-        (axis2_env_t *)env,
+    guththila_write_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         prefix, namespace_uri);
     return AXIS2_SUCCESS;
-
-}
-
+}

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_default_namespace(axiom_xml_writer_t *writer,
-													 const axis2_env_t *env,
-													 axis2_char_t *namespace_uri)
+    const axis2_env_t *env,
+    axis2_char_t *namespace_uri)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE);
-    guththila_write_default_namespace(
-        (axis2_env_t *)env,
+    guththila_write_default_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         namespace_uri);
     return AXIS2_SUCCESS;
-
 }

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_comment(axiom_xml_writer_t *writer,
-										   const axis2_env_t *env,
-										   axis2_char_t *value)
+    const axis2_env_t *env,
+    axis2_char_t *value)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);
-    guththila_write_comment(
-        (axis2_env_t *)env,
+    guththila_write_comment((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         value);
     return AXIS2_SUCCESS;
-
-}
-
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_processing_instruction(
-    axiom_xml_writer_t *writer,
+}
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_processing_instruction(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *target)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, target, AXIS2_FAILURE);
-    /*     return guththila_write_processing_instruction( */
-    /*                     (axis2_env_t *)env, */
-    /*                     AXIS2_INTF_TO_IMPL(writer)->parser, */
-    /*                     target); */
-    return AXIS2_SUCCESS;
-
-}
-
-axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_processing_instruction_data(
-    axiom_xml_writer_t *writer,
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+guththila_xml_writer_wrapper_write_processing_instruction_data(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *target,
     axis2_char_t *data)
@@ -783,31 +708,23 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, target, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE);
-    /*     return guththila_write_processing_instruction_data( */
-    /*                     (axis2_env_t *)env, */
-    /*                     AXIS2_INTF_TO_IMPL(writer)->parser, */
-    /*                     target, data); */
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_cdata(axiom_xml_writer_t *writer,
-										 const axis2_env_t *env,
-										 axis2_char_t *data)
+    const axis2_env_t *env,
+    axis2_char_t *data)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE);
-    /*     return guththila_write_cdata( */
-    /*                     (axis2_env_t *)env, */
-    /*                     AXIS2_INTF_TO_IMPL(writer)->parser, */
-    /*                     data); */
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_dtd(axiom_xml_writer_t *writer,
-									   const axis2_env_t *env,
-									   axis2_char_t *dtd)
+    const axis2_env_t *env,
+    axis2_char_t *dtd)
 {
     /* AXIS2_ENV_CHECK( env, AXIS2_FAILURE); */
     /*     AXIS2_PARAM_CHECK(env->error, dtd, AXIS2_FAILURE); */
@@ -819,8 +736,7 @@
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_entity_ref(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_entity_ref(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *name)
 {
@@ -840,33 +756,25 @@
     const axis2_env_t *env)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    guththila_write_start_document(
-        (axis2_env_t *)env,
+    guththila_write_start_document((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser);
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_document_with_version(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_start_document_with_version(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *version)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, version, AXIS2_FAILURE);
-    /* return guththila_write_start_document_with_version( */
-    /*                     (axis2_env_t *)env, */
-    /*                     AXIS2_INTF_TO_IMPL(writer)->parser, */
-    /*                     version); */
-    guththila_write_start_document(
-        (axis2_env_t *)env,
+    guththila_write_start_document((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser);
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_start_document_with_version_encoding(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_start_document_with_version_encoding(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *encoding,
     axis2_char_t *version)
@@ -874,28 +782,20 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, encoding, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, version, AXIS2_FAILURE);
-
-    /*     return guththila_write_start_document_with_version_encoding( */
-    /*                     (axis2_env_t *)env, */
-    /*                     AXIS2_INTF_TO_IMPL(writer)->parser, */
-    /*                     encoding, version); */
-    guththila_write_start_document(
-        (axis2_env_t *)env,
+    guththila_write_start_document((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser);
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_characters(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_characters(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *text)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE);
-    guththila_write_characters(
-        (axis2_env_t *)env,
+    guththila_write_characters((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser,
         text);
     return AXIS2_SUCCESS;
@@ -903,93 +803,88 @@

 axis2_char_t* AXIS2_CALL
 guththila_xml_writer_wrapper_get_prefix(axiom_xml_writer_t *writer,
-										const axis2_env_t *env,
-										axis2_char_t *uri)
+    const axis2_env_t *env,
+    axis2_char_t *uri)
 {
     AXIS2_ENV_CHECK(env, NULL);
     AXIS2_PARAM_CHECK(env->error, uri, NULL);
-    return guththila_get_prefix_for_namespace(
-		(axis2_env_t *)env,
-		AXIS2_INTF_TO_IMPL(writer)->parser, uri);
+    return guththila_get_prefix_for_namespace((axis2_env_t *)env,
+        AXIS2_INTF_TO_IMPL(writer)->parser, uri);
 }

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_set_prefix(axiom_xml_writer_t *writer,
-										const axis2_env_t *env,
-										axis2_char_t *prefix,
-										axis2_char_t *uri)
+    const axis2_env_t *env,
+    axis2_char_t *prefix,
+    axis2_char_t *uri)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE);
-    guththila_write_namespace(
-        (axis2_env_t *)env,
+    guththila_write_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser, prefix, uri);
     return AXIS2_SUCCESS;

 }
 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_set_default_prefix(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_set_default_prefix(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *uri)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE);
-    guththila_write_default_namespace(
-        (axis2_env_t *)env,
+    guththila_write_default_namespace((axis2_env_t *)env,
         AXIS2_INTF_TO_IMPL(writer)->parser, uri);
     return AXIS2_SUCCESS;
 }

 axis2_status_t AXIS2_CALL
-guththila_xml_writer_wrapper_write_encoded(
-    axiom_xml_writer_t *writer,
+guththila_xml_writer_wrapper_write_encoded(axiom_xml_writer_t *writer,
     const axis2_env_t *env,
     axis2_char_t *text,
     int in_attr)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE);
-    /*     return guththila_write_encoded( */
-    /*                     (axis2_env_t *)env, */
-    /*                     AXIS2_INTF_TO_IMPL(writer)->parser, text,
-						   in_attr); */
     return AXIS2_SUCCESS;
 }

 void* AXIS2_CALL
 guththila_xml_writer_wrapper_get_xml(axiom_xml_writer_t *writer,
-									 const axis2_env_t *env)
+    const axis2_env_t *env)
 {
     char *buffer = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     buffer = guththila_get_memory_buffer((axis2_env_t *)env,
-										 AXIS2_INTF_TO_IMPL(writer)->parser);
+        AXIS2_INTF_TO_IMPL(writer)->parser);
     return (void*)buffer ;
 }

 axis2_status_t AXIS2_CALL
 guththila_xml_writer_wrapper_write_raw (axiom_xml_writer_t *writer,
-										const axis2_env_t *env,
-										axis2_char_t *content)
-{
-	if (!content)
-		return AXIS2_FAILURE;
-	else
-	{
-		guththila_write_to_buffer ((axis2_env_t *)env,
-								   AXIS2_INTF_TO_IMPL (writer)->parser,
-								   (const axis2_char_t *) content);
-		return  AXIS2_SUCCESS;
-	}
+    const axis2_env_t *env,
+    axis2_char_t *content)
+{
+    if (!content)
+    {
+        return AXIS2_FAILURE;
+    }
+    else
+    {
+        guththila_write_to_buffer ((axis2_env_t *)env,
+            AXIS2_INTF_TO_IMPL (writer)->parser,
+            (const axis2_char_t *) content);
+        return  AXIS2_SUCCESS;
+    }
 }

 unsigned int AXIS2_CALL
-guththila_xml_writer_wrapper_get_xml_size (	axiom_xml_writer_t *writer,
-											const axis2_env_t *env)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-	return guththila_get_memory_buffer_size ((axis2_env_t *)env,
-											 AXIS2_INTF_TO_IMPL(writer)->parser);
-}
+guththila_xml_writer_wrapper_get_xml_size (axiom_xml_writer_t *writer,
+    const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    return guththila_get_memory_buffer_size ((axis2_env_t *)env,
+        AXIS2_INTF_TO_IMPL(writer)->parser);
+}
+
+


ALSA: usb-audio: 6fire: return correct XRUN indication

Return SNDRV_PCM_POS_XRUN (snd_pcm_uframes_t) instead of
SNDRV_PCM_STATE_XRUN (snd_pcm_state_t) from the pointer
function of 6fire, as expected by snd_pcm_update_hw_ptr0().

Caught by sparse.

Signed-off-by: Eldad Zack <46870ccd9486ced5844a21b823ddb0e89874ecb6@fogrefinery.com>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/usb/6fire/pcm.c
+++ sound/usb/6fire/pcm.c
@@ -543,7 +543,7 @@
 	snd_pcm_uframes_t ret;

 	if (rt->panic || !sub)
-		return SNDRV_PCM_STATE_XRUN;
+		return SNDRV_PCM_POS_XRUN;

 	spin_lock_irqsave(&sub->lock, flags);
 	ret = sub->dma_off;


elementary/ctxpopup - patched by cnook <kimcinoo@gmail.com>

Hi All,

The ctxpopup arrow is attached on the drag-able part.
If arrow height/width is smaller than drag-able part,
then there is a gap between arrow and ctxpopup base.
So this patch comes for resolving this issue. Thanks.

Sincerely,
Shinwoo Kim.

SVN revision: 61462

--- src/lib/elc_ctxpopup.c
+++ src/lib/elc_ctxpopup.c
@@ -493,7 +493,7 @@
                 y = base_size.h - arrow_size.h;
               else
                 y = y - base_size.y - (arrow_size.h * 0.5);
-              edje_object_part_drag_value_set(wd->base, "elm.swallow.arrow_left", 0.5,
+              edje_object_part_drag_value_set(wd->base, "elm.swallow.arrow_left", 1,
                                               (double) (y) / (double) (base_size.h - arrow_size.h));
            }
          break;
@@ -507,7 +507,7 @@
               else if (y > (base_size.y + base_size.h - (arrow_size.h * 0.5)))
                 y = base_size.h - arrow_size.h;
               else y = y - base_size.y - (arrow_size.h * 0.5);
-              edje_object_part_drag_value_set(wd->base, "elm.swallow.arrow_right", 0.5,
+              edje_object_part_drag_value_set(wd->base, "elm.swallow.arrow_right", 0,
                                               (double) (y) / (double) (base_size.h - arrow_size.h));
             }
          break;
@@ -523,7 +523,7 @@
               else
                 x = x - base_size.x - (arrow_size.w * 0.5);
               edje_object_part_drag_value_set(wd->base, "elm.swallow.arrow_up",
-                                              (double) (x) / (double) (base_size.w - arrow_size.w), 0.5);
+                                              (double) (x) / (double) (base_size.w - arrow_size.w), 1);
            }
          break;
       case ELM_CTXPOPUP_DIRECTION_DOWN:
@@ -537,7 +537,7 @@
                 x = base_size.w - arrow_size.w;
               else x = x - base_size.x - (arrow_size.w * 0.5);
               edje_object_part_drag_value_set(wd->base, "elm.swallow.arrow_down",
-                                              (double) (x) / (double) (base_size.w - arrow_size.w), 0.5);
+                                              (double) (x) / (double) (base_size.w - arrow_size.w), 0);
            }
          break;
       default:


templatize get/putInt functions

templatize get/putInt functions

--- src/core/Util.h
+++ src/core/Util.h
@@ -62,7 +62,7 @@
                         unsigned char *cbcbuffer);

-// XXX TODO templatize the following, bonus for getting unsigned versions too XXX
+// The following can be used directly or via template functions getInt<> / putInt<>

 /*
 * Get an integer that is stored in little-endian format
@@ -158,6 +158,35 @@
 #error Is the target CPU big or little endian?
 #endif
 }
+
+inline void putInt64(unsigned char buf[8], const int64 val )
+{
+#if defined(PWS_LITTLE_ENDIAN)
+  *reinterpret_cast<int64 *>(buf) = val;
+#elif defined(PWS_BIG_ENDIAN)
+  buf[0] = val & 0xFF;
+  buf[1] = (val >> 8) & 0xFF;
+  buf[2] = (val >> 16) & 0xFF;
+  buf[3] = (val >> 24) & 0xFF;
+  buf[4] = (val >> 32) & 0xFF;
+  buf[5] = (val >> 40) & 0xFF;
+  buf[6] = (val >> 48) & 0xFF;
+  buf[7] = (val >> 56) & 0xFF;
+#else
+#error Is the target CPU big or little endian?
+#endif
+}
+
+// And now let's wrap some template functions around the above:
+template<typename T> T getInt(const unsigned char *buf) {}
+template<> inline int16 getInt<int16>(const unsigned char *buf) {return getInt16(buf);}
+template<> inline int32 getInt<int32>(const unsigned char *buf) {return getInt32(buf);}
+template<> inline int64 getInt<int64>(const unsigned char *buf) {return getInt64(buf);}
+
+template<typename T> void putInt(unsigned char *buf, const T val) {}
+template<> inline void putInt<int16>(unsigned char *buf, const int16 val) {putInt16(buf, val);}
+template<> inline void putInt<int32>(unsigned char *buf, const int32 val) {putInt32(buf, val);}
+template<> inline void putInt<int64>(unsigned char *buf, const int64 val) {putInt64(buf, val);}

 bool operator==(const std::string& str1, const stringT& str2);
 inline bool operator==(const stringT& str1, const std::string &str2) { return str2 == str1; }


CGA raster effect, begin

CGA raster effect, begin

--- hw/vga/test.c
+++ hw/vga/test.c
@@ -16,6 +16,7 @@
 #include <hw/cpu/cpu.h>
 #include <hw/dos/dos.h>
 #include <hw/vga/vga.h>
+#include <hw/8259/8259.h>
 #include <hw/vga/vgatty.h>
 #include <hw/dos/doswin.h>

@@ -240,7 +241,7 @@
 		else
 			vga_write("  9: VGA 9-bit wide \n");
 		vga_write("  z: Measurements     o: Change overscan\n");
-        vga_write("  @: CGA snow test\n");
+        vga_write("  @: CGA snow test    #. CGA mode scan fx\n");

 		vga_write("ESC: quit\n");
 		vga_write_sync();
@@ -2396,6 +2397,125 @@
 				while (getch() != 13);
 			}
 		}
+        else if (c == '#') {
+			if ((vga_state.vga_flags & (VGA_IS_VGA|VGA_IS_EGA)) || !(vga_state.vga_flags & VGA_IS_CGA)) {
+				vga_write("Only CGA or compatible may do that\n");
+				vga_write_sync();
+				vga_sync_bios_cursor();
+				while (getch() != 13);
+            }
+            else {
+                unsigned short row=1; /* cannot be zero */
+                unsigned short rowa=1;
+                unsigned short rowheight=30;
+
+				int10_setmode(4); /* set to 40x25 for this one */
+                update_state_from_vga();
+
+                vga_clear();
+                vga_moveto(0,0);
+                vga_write_color(7);
+                vga_write("40x25 mode select raster fx test.\n");
+                vga_write("Hit ESC at any time to stop.\n");
+
+                _cli();
+                do {
+                    if (inp(0x64) & 1) { // NTS: This is clever because on IBM PC hardware port 64h is an alias of 60h.
+                        unsigned char c = inp(0x60); // chances are the scancode has bit 0 set.
+
+                        if (c != 0 && (c & 0x80) == 0)
+                            break;
+                    }
+
+                    {
+                        unsigned char x = inp(0x61) & 0x7F;
+                        outp(0x61,x | 0x80);
+                        outp(0x61,x);
+
+                        outp(0x20,P8259_OCW2_SPECIFIC_EOI | 1); // IRQ1
+                    }
+
+                    __asm {
+                        push        cx
+                        push        dx
+
+                        ; wait for vsync
+                        mov         dx,3DAh
+wvsync:                 in          al,dx
+                        test        al,8
+                        jz          wvsync
+
+                        ; wait for vsync end
+wvsyncend:              in          al,dx
+                        test        al,8
+                        jnz         wvsyncend
+
+                        ; okay, change background color
+                        mov         dx,3D9h
+                        mov         al,00h
+                        out         dx,al
+
+                        ; count scanlines
+                        mov         dx,3DAh
+                        mov         cx,row
+countup1:               in          al,dx       ; wait for hsync
+                        test        al,1
+                        jz          countup1
+
+countup2:               in          al,dx       ; wait for hsync end
+                        test        al,1
+                        jnz         countup2
+                        loop        countup1    ; count rows
+
+                        ; okay, change background color
+                        mov         dx,3D9h
+                        mov         al,01h
+                        out         dx,al
+
+                        ; count scanlines again
+                        mov         dx,3DAh
+                        mov         cx,rowheight
+countup3:               in          al,dx       ; wait for hsync
+                        test        al,1
+                        jz          countup3
+
+countup4:               in          al,dx       ; wait for hsync end
+                        test        al,1
+                        jnz         countup4
+                        loop        countup3    ; count rows
+
+                        ; okay, change background color
+                        mov         dx,3D9h
+                        mov         al,00h
+                        out         dx,al
+
+                        pop         dx
+                        pop         cx
+                    }
+
+                    row += rowa;
+                    if ((row+rowheight) >= 198)
+                        rowa = ~0;
+                    else if (row == 1)
+                        rowa = 1;
+                } while(1);
+
+                {
+                    unsigned char x = inp(0x61) & 0x7F;
+                    outp(0x61,x | 0x80);
+                    outp(0x61,x);
+
+                    outp(0x20,P8259_OCW2_SPECIFIC_EOI | 1); // IRQ1
+                }
+
+                _sti();
+
+                while (kbhit()) getch();
+
+				int10_setmode(3);
+                update_state_from_vga();
+            }
+        }
         else if (c == '@') {
             unsigned char c = 219; /* solid block */
             unsigned char write16 = 1;


Fix initializing SDL_window

Fix initializing SDL_window

--- jni/src/AAAA-Engine/zcore.c
+++ jni/src/AAAA-Engine/zcore.c
@@ -201,25 +201,30 @@

 #ifdef ANDROID_NDK
     // EXL: Android OpenGLES 1.1 via SDL2 initialization
-    globalWindow = SDL_CreateWindow("AAAA", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
-                                    screenwidth, screenheight, SDL_WINDOW_OPENGL);
-
-    TO_DEBUG_LOG("Init SDL window: %dx%d\n", screenwidth, screenheight);
-    SDL_SetWindowFullscreen(globalWindow, SDL_TRUE);
-
-    // Update Size
-    SDL_GetWindowSize(globalWindow, &screenwidth, &screenheight);
-    TO_DEBUG_LOG("Resize SDL window: %dx%d\n", screenwidth, screenheight);
-
     SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
     SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8);
     SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8);
     SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,24);
     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,0);
+    SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE,0);
+    SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE,0);
+    SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE,0);
+    SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE,0);

     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); // TODO: Check this.
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
+
+    globalWindow = SDL_CreateWindow("AAAA", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+                                    screenwidth, screenheight, SDL_WINDOW_OPENGL);
+
+    TO_DEBUG_LOG("Init SDL window: %dx%d\n", screenwidth, screenheight);
+    SDL_SetWindowFullscreen(globalWindow, SDL_TRUE);
+
+    // Update Size
+    SDL_GetWindowSize(globalWindow, &screenwidth, &screenheight);
+    TO_DEBUG_LOG("Resize SDL window: %dx%d\n", screenwidth, screenheight);

     glContext_SDL = SDL_GL_CreateContext(globalWindow);


Fixed paintControlBackground() on Windows; there is no longera guarantee of every control being put on top of a container.

--- newctrl/common_windows.c
+++ newctrl/common_windows.c
@@ -106,13 +106,8 @@
 	for (;;) {
 		parent = GetParent(parent);
 		if (parent == NULL)
-			xpanic("error getting parent container of control in paintControlBackground()", GetLastError());
+			xpanic("error getting parent control of control in paintControlBackground()", GetLastError());
 		// wine sends these messages early, yay...
-		if (parent == msgwin)
-			return;
-		parent = GetParent(parent);
-		if (parent == NULL)
-			xpanic("error getting parent control of control in paintControlBackground()", GetLastError());
 		if (parent == msgwin)
 			return;
 		if (GetClassNameW(parent, classname, 128) == 0)


area: Use unordered maps and sets

area: Use unordered maps and sets

--- src/core/area.h
+++ src/core/area.h
@@ -28,9 +28,9 @@
 #ifndef SRC_CORE_AREA_H_
 #define SRC_CORE_AREA_H_

-#include <map>
-#include <set>
 #include <string>
+#include <unordered_map>
+#include <unordered_set>

 #include "core/entity.h"
 #include "core/tile.h"
@@ -163,12 +163,12 @@
     Player* player;
     uint32_t colorOverlayARGB;

-    std::set<Rc<Character>> characters;
-    std::set<Rc<Overlay>> overlays;
+    std::unordered_set<Rc<Character>> characters;
+    std::unordered_set<Rc<Overlay>> overlays;

     TileGrid<Tile> grid;

-    std::map<std::string, TileSet> tileSets;
+    std::unordered_map<std::string, TileSet> tileSets;

     std::string name, author;


Rename the UART ISR in the MSP430X/CCS demo to match the UART actually being used.

--- Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/serial.c
+++ Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/serial.c
@@ -158,7 +158,7 @@
 /*-----------------------------------------------------------*/

 #pragma vector=USCI_A1_VECTOR
-interrupt void prvUSCI_A0_ISR( void )
+interrupt void prvUSCI_A1_ISR( void )
 {
 signed portCHAR cChar;
 portBASE_TYPE xTaskWoken = pdFALSE;


dotlocking: Small code cleanups.

dotlocking: Small code cleanups.

--- src/lib/file-dotlock.c
+++ src/lib/file-dotlock.c
@@ -70,7 +70,7 @@
 };

 static struct dotlock *
-file_dotlock_alloc(const struct dotlock_settings *settings)
+file_dotlock_alloc(const struct dotlock_settings *settings, const char *path)
 {
 	struct dotlock *dotlock;

@@ -78,6 +78,7 @@
 	dotlock->settings = *settings;
 	if (dotlock->settings.lock_suffix == NULL)
 		dotlock->settings.lock_suffix = DEFAULT_LOCK_SUFFIX;
+	dotlock->path = i_strdup(path);
 	dotlock->fd = -1;

 	return dotlock;
@@ -446,9 +447,9 @@
 	io_loop_destroy(&ioloop);
 }

-static int dotlock_create(const char *path, struct dotlock *dotlock,
-			  enum dotlock_create_flags flags, bool write_pid,
-			  const char **lock_path_r)
+static int
+dotlock_create(struct dotlock *dotlock, enum dotlock_create_flags flags,
+	       bool write_pid, const char **lock_path_r)
 {
 	const struct dotlock_settings *set = &dotlock->settings;
 	const char *lock_path;
@@ -463,14 +464,15 @@

 	now = time(NULL);

-	lock_path = *lock_path_r = t_strconcat(path, set->lock_suffix, NULL);
+	lock_path = *lock_path_r =
+		t_strconcat(dotlock->path, set->lock_suffix, NULL);
 	stale_notify_threshold = set->stale_timeout / 2;
 	max_wait_time = (flags & DOTLOCK_CREATE_FLAG_NONBLOCK) != 0 ? 0 :
 		now + set->timeout;
 	tmp_path = t_str_new(256);

 	memset(&lock_info, 0, sizeof(lock_info));
-	lock_info.path = path;
+	lock_info.path = dotlock->path;
 	lock_info.set = set;
 	lock_info.lock_path = lock_path;
 	lock_info.fd = -1;
@@ -534,7 +536,6 @@
 			dotlock->dev = st.st_dev;
 			dotlock->ino = st.st_ino;

-			dotlock->path = i_strdup(path);
 			dotlock->fd = lock_info.fd;
                         dotlock->lock_time = now;
 			lock_info.fd = -1;
@@ -544,7 +545,7 @@
 				i_warning("Created dotlock file's timestamp is "
 					  "different than current time "
 					  "(%s vs %s): %s", dec2str(st.st_ctime),
-					  dec2str(now), path);
+					  dec2str(now), dotlock->path);
 			}
 		}
 	}
@@ -586,14 +587,14 @@
 	i_free(dotlock);
 }

-static int file_dotlock_create_real(struct dotlock *dotlock, const char *path,
+static int file_dotlock_create_real(struct dotlock *dotlock,
 				    enum dotlock_create_flags flags)
 {
 	const char *lock_path;
 	struct stat st;
 	int fd, ret;

-	ret = dotlock_create(path, dotlock, flags, TRUE, &lock_path);
+	ret = dotlock_create(dotlock, flags, TRUE, &lock_path);
 	if (ret <= 0 || (flags & DOTLOCK_CREATE_FLAG_CHECKONLY) != 0)
 		return ret;

@@ -635,9 +636,9 @@
 	struct dotlock *dotlock;
 	int ret;

-	dotlock = file_dotlock_alloc(set);
+	dotlock = file_dotlock_alloc(set, path);
 	T_BEGIN {
-		ret = file_dotlock_create_real(dotlock, path, flags);
+		ret = file_dotlock_create_real(dotlock, flags);
 	} T_END;
 	if (ret <= 0 || (flags & DOTLOCK_CREATE_FLAG_CHECKONLY) != 0)
 		file_dotlock_free(&dotlock);
@@ -713,11 +714,11 @@
 	struct dotlock *dotlock;
 	int ret;

-	dotlock = file_dotlock_alloc(set);
+	dotlock = file_dotlock_alloc(set, path);
 	T_BEGIN {
 		const char *lock_path;

-		ret = dotlock_create(path, dotlock, flags, FALSE, &lock_path);
+		ret = dotlock_create(dotlock, flags, FALSE, &lock_path);
 	} T_END;

 	if (ret <= 0) {


Add code example

Add code example

--- SNNeuralNet/SNNeuralNet.h
+++ SNNeuralNet/SNNeuralNet.h
@@ -31,11 +31,27 @@
 #define SNOutput(...) SNInput(__VA_ARGS__)

 /**
- *  Represents a neural network. After creating a network with a specified number of inputs,
- *  outputs, and hidden layers, use the train:numRecords: method to train the network with an
- *  array of SNTrainingRecord structures. Then use the runInput: method to predict output for
- *  unknown inputs.
- */
+Represents a neural network. After creating a network with a specified number of inputs,
+outputs, and hidden layers, use the train:numRecords: method to train the network with an
+array of SNTrainingRecord structures. Then use the runInput: method to predict output for
+unknown inputs.
+
+This example approximates the XOR function using a neural network:
+
+    #import "SNNeuralNet.h"
+
+    SNTrainingRecord records[] = {
+        {SNInput(0,0), SNOutput(0)},
+        {SNInput(0,1), SNOutput(1)},
+        {SNInput(1,0), SNOutput(1)},
+        {SNInput(1,1), SNOutput(0)}
+    };
+
+    SNNeuralNet *net = [[SNNeuralNet alloc] initWithTrainingData:records numRecords:4 numInputs:2 numOutputs:1];
+
+    double *output = [net runInput:SNInput(1, 0)];
+    printf("%f\n", output[0]); // 0.987
+*/
 @interface SNNeuralNet : NSObject <NSCoding>

 /// @name Initializing a neural network


logic directive

logic directive

--- ngx_http_geoip2_module.c
+++ ngx_http_geoip2_module.c
@@ -37,7 +37,7 @@
 } ngx_http_geoip2_ctx_t;

-static ngx_int_t ngx_http_geoip2_variable(ngx_http_request_t *r,
+static ngx_int_t ngx_http_geoip2_variable(ngx_conf_t *cf, ngx_http_request_t *r,
     ngx_http_variable_value_t *v, uintptr_t data);
 static void *ngx_http_geoip2_create_conf(ngx_conf_t *cf);
 static char *ngx_http_geoip2_init_conf(ngx_conf_t *cf, void *conf);
@@ -173,7 +173,7 @@
 //}

 static ngx_int_t
-ngx_http_geoip2_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
+ngx_http_geoip2_variable(ngx_conf_t *cf, ngx_http_request_t *r, ngx_http_variable_value_t *v,
     uintptr_t data)
 {
     ngx_http_geoip2_ctx_t   *geoip2 = (ngx_http_geoip2_ctx_t *) data;
@@ -209,6 +209,9 @@

         xfwd = &r->headers_in.x_forwarded_for;
         if (xfwd->nelts > 0 && gcf->first_non_private_ip) {
+
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "first_non_private_ip active");
+
             ngx_uint_t          i;
             ngx_table_elt_t     **h;


typo in debug message

typo in debug message

--- src/core/core.c
+++ src/core/core.c
@@ -367,7 +367,7 @@
 {
      DFBResult ret;

-     DEBUGMSG( "DirectFB/Core: we are the master, initializeing...\n" );
+     DEBUGMSG( "DirectFB/Core: we are the master, initializing...\n" );

      dfb_core->arena  = arena;
      dfb_core->master = 1;


REFAC: Typo.

REFAC: Typo.

--- Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h
+++ Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h
@@ -133,7 +133,7 @@
   std::string GetGeoidFile() const;

   /**
-   * Removes all the ossimElevationDatabases from the ossimElevManager.
+   * Remove all the ossimElevationDatabases from the ossimElevManager.
    */
   void ClearDEMs();


file-dotlock: Avoid "timestamp is different than current time" errors during high disk I/O load.

--- src/lib/file-dotlock.c
+++ src/lib/file-dotlock.c
@@ -534,8 +534,13 @@
 				try_create_lock_excl(&lock_info, write_pid) :
 				try_create_lock_hardlink(&lock_info, write_pid,
 							 tmp_path, now);
-			if (ret != 0)
+			if (ret != 0) {
+				/* if we succeeded, get the current time once
+				   more in case disk I/O usage was really high
+				   and it took a long time to create the lock */
+				now = time(NULL);
 				break;
+			}
 		}

 		if (last_notify != now && set->callback != NULL) {