clean up simta_lmdb.c

clean up simta_lmdb.c

--- simta_lmdb.c
+++ simta_lmdb.c
@@ -1,14 +1,14 @@
+/*
+ * Copyright (c) Regents of The University of Michigan
+ * See COPYING.
+ */
+
 #include "config.h"

-#include <sys/param.h>
 #include <inttypes.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

-#include <lmdb.h>
-#include <yasl.h>
-
 #include "simta_lmdb.h"

 static int simta_db_open( struct simta_dbh **, const char *, uint32_t, int );
@@ -16,23 +16,23 @@
     static int
 simta_db_open( struct simta_dbh **dbh, const char *file, uint32_t flags, int mode )
 {
-    int		ret;
-    MDB_env	*dbp;
+    int         ret;
+    MDB_env     *dbp;

     *dbh = calloc( 1, sizeof( struct simta_dbh ));

     if (( ret = mdb_env_create( &dbp )) != 0 ) {
-	return( ret );
+        return( ret );
     }

     if (( ret = mdb_env_set_mapsize( dbp, 104857600 )) != 0 ) {
-	return( ret );
+        return( ret );
     }

     if (( ret = mdb_env_open( dbp, file, flags, 0664 )) != 0 ) {
-	mdb_env_close( dbp );
+        mdb_env_close( dbp );
     } else {
-	(*dbh)->h_env = dbp;
+        (*dbh)->h_env = dbp;
     }

     return( SIMTA_DB_OK );
@@ -42,10 +42,10 @@
 simta_db_strerror( int err ) {
     switch ( err ) {
     case SIMTA_DB_SYSERROR:
-	return( "System Error" );
+        return( "System Error" );
     case SIMTA_DB_NOTFOUND:
-	err = MDB_NOTFOUND;
-	break;
+        err = MDB_NOTFOUND;
+        break;
     }
     return( mdb_strerror( err ));
 }
@@ -60,32 +60,32 @@
 simta_db_open_r( struct simta_dbh **dbh, const char *file )
 {
     return( simta_db_open( dbh, file,
-	    MDB_NOSUBDIR | MDB_NOLOCK | MDB_RDONLY, 0664 ));
+            MDB_NOSUBDIR | MDB_NOLOCK | MDB_RDONLY, 0664 ));
 }

     int
 simta_db_new( struct simta_dbh **dbh, const char *file )
 {
-    int		ret;
-    MDB_txn	*txn;
-    MDB_dbi	dbi;
+    int         ret;
+    MDB_txn     *txn;
+    MDB_dbi     dbi;

     if (( ret = simta_db_open_rw( dbh, file )) != 0 ) {
-	return( ret );
+        return( ret );
     }

     if (( ret = mdb_txn_begin( (*dbh)->h_env, NULL, 0, &txn )) != 0 ) {
-	goto cleanup;
+        goto cleanup;
     }

     if (( ret =
-	    mdb_dbi_open( txn, NULL, MDB_CREATE | MDB_DUPSORT, &dbi )) != 0 ) {
-	goto cleanup;
+            mdb_dbi_open( txn, NULL, MDB_CREATE | MDB_DUPSORT, &dbi )) != 0 ) {
+        goto cleanup;
     }

     if (( ret = mdb_drop( txn, dbi, 0 )) == 0 ) {
-	ret = mdb_txn_commit( txn );
-	return( ret );
+        ret = mdb_txn_commit( txn );
+        return( ret );
     }

 cleanup:
@@ -97,10 +97,10 @@
     int
 simta_db_put( struct simta_dbh *dbh, yastr key, yastr value )
 {
-    int		ret;
-    MDB_val	db_key, db_value;
-    MDB_txn	*txn;
-    MDB_dbi	dbi;
+    int         ret;
+    MDB_val     db_key, db_value;
+    MDB_txn     *txn;
+    MDB_dbi     dbi;

     memset( &db_key, 0, sizeof( MDB_val ));
     memset( &db_value, 0, sizeof( MDB_val ));
@@ -111,16 +111,16 @@
     db_value.mv_size = yasllen( value );

     if (( ret = mdb_txn_begin( dbh->h_env, NULL, 0, &txn )) != 0 ) {
-	return( ret );
+        return( ret );
     }

     if (( ret = mdb_dbi_open( txn, NULL, MDB_DUPSORT, &dbi )) != 0 ) {
-	goto cleanup;
+        goto cleanup;
     }

     if (( ret = mdb_put( txn, dbi, &db_key, &db_value, 0 )) == 0 ) {
-	ret = mdb_txn_commit( txn );
-	return( ret );
+        ret = mdb_txn_commit( txn );
+        return( ret );
     }

 cleanup:
@@ -131,31 +131,31 @@
     int
 simta_db_get( struct simta_dbh *dbh, yastr key, yastr *value )
 {
-    MDB_val	db_key, db_value;
-    MDB_txn	*txn;
-    MDB_dbi	dbi;
-    int		ret;
+    MDB_val     db_key, db_value;
+    MDB_txn     *txn;
+    MDB_dbi     dbi;
+    int         ret;

     memset( &db_key, 0, sizeof( MDB_val ));
     db_key.mv_data = key;
     db_key.mv_size = yasllen( key );

     if (( ret = mdb_txn_begin( dbh->h_env, NULL, MDB_RDONLY, &txn )) != 0 ) {
-	return( ret );
+        return( ret );
     }

     if (( ret = mdb_dbi_open( txn, NULL, MDB_DUPSORT, &dbi )) != 0 ) {
-	goto cleanup;
+        goto cleanup;
     }

     if (( ret = mdb_get( txn, dbi, &db_key, &db_value )) != 0 ) {
-	goto cleanup;
+        goto cleanup;
     }

     *value = yaslnew( db_value.mv_data, db_value.mv_size );

     if ( ret == MDB_NOTFOUND ) {
-	ret = SIMTA_DB_NOTFOUND;
+        ret = SIMTA_DB_NOTFOUND;
     }

 cleanup:
@@ -166,24 +166,24 @@
     int
 simta_db_cursor_open( struct simta_dbh *dbh, struct simta_dbc **dbc )
 {
-    int 	ret;
-    MDB_txn	*txn;
-    MDB_cursor	*dbcp;
-    MDB_dbi	dbi;
+    int         ret;
+    MDB_txn     *txn;
+    MDB_cursor  *dbcp;
+    MDB_dbi     dbi;

     *dbc = calloc( 1, sizeof( struct simta_dbc ));

     if (( ret = mdb_txn_begin( dbh->h_env, NULL, MDB_RDONLY, &txn )) != 0 ) {
-	return( ret );
+        return( ret );
     }

     if (( ret = mdb_dbi_open( txn, NULL, MDB_DUPSORT, &dbi )) != 0 ) {
-	goto cleanup;
+        goto cleanup;
     }

     if (( ret = mdb_cursor_open( txn, dbi, &dbcp )) == 0 ) {
-	(*dbc)->c_cursor = dbcp;
-	return( ret );
+        (*dbc)->c_cursor = dbcp;
+        return( ret );
     }

 cleanup:
@@ -194,47 +194,47 @@
     int
 simta_db_cursor_get( struct simta_dbc *dbc, yastr *key, yastr *value )
 {
-    MDB_val		db_key, db_value;
-    MDB_cursor_op	op;
-    int			ret;
+    MDB_val             db_key, db_value;
+    MDB_cursor_op       op;
+    int                 ret;

     if ( dbc->c_init == 0 ) {
-	if (( *key != NULL ) && ( yasllen( *key ) > 0 )) {
-	    memset( &db_key, 0, sizeof( MDB_val ));
-	    db_key.mv_data = *key;
-	    db_key.mv_size = yasllen( *key );
-	    dbc->c_keyed = 1;
-	    op = MDB_SET;
-	} else {
-	    op = MDB_FIRST;
-	}
-	dbc->c_init = 1;
+        if (( *key != NULL ) && ( yasllen( *key ) > 0 )) {
+            memset( &db_key, 0, sizeof( MDB_val ));
+            db_key.mv_data = *key;
+            db_key.mv_size = yasllen( *key );
+            dbc->c_keyed = 1;
+            op = MDB_SET;
+        } else {
+            op = MDB_FIRST;
+        }
+        dbc->c_init = 1;
     } else if ( dbc->c_keyed == 1 ) {
-	op = MDB_NEXT_DUP;
+        op = MDB_NEXT_DUP;
     } else {
-	op = MDB_NEXT;
+        op = MDB_NEXT;
     }

     if (( ret = mdb_cursor_get( dbc->c_cursor, &db_key, &db_value,
-	    op )) != 0 ) {
-	if ( ret == MDB_NOTFOUND ) {
-	    ret = SIMTA_DB_NOTFOUND;
-	}
-	return( ret );
+            op )) != 0 ) {
+        if ( ret == MDB_NOTFOUND ) {
+            ret = SIMTA_DB_NOTFOUND;
+        }
+        return( ret );
     }

     if (( ret = mdb_cursor_get( dbc->c_cursor, &db_key, &db_value,
-	    MDB_GET_CURRENT )) != 0 ) {
-	return( ret );
+            MDB_GET_CURRENT )) != 0 ) {
+        return( ret );
     }

     if ( *key == NULL ) {
-	*key = yaslempty( );
+        *key = yaslempty( );
     }
     *key = yaslcpylen( *key, db_key.mv_data, db_key.mv_size );

     if ( *value == NULL ) {
-	*value = yaslempty( );
+        *value = yaslempty( );
     }
     *value = yaslcpylen( *value, db_value.mv_data, db_value.mv_size );

@@ -245,10 +245,10 @@
 simta_db_cursor_close( struct simta_dbc *dbc )
 {
     if ( dbc == NULL ) {
-	return;
+        return;
     }
     if ( dbc->c_cursor != NULL ) {
-	mdb_txn_abort( mdb_cursor_txn( dbc->c_cursor ));
+        mdb_txn_abort( mdb_cursor_txn( dbc->c_cursor ));
     }
     free( dbc );
 }
@@ -257,12 +257,13 @@
 simta_db_close( struct simta_dbh *dbh )
 {
     if ( dbh == NULL ) {
-	return;
+        return;
     }
     if ( dbh->h_env != NULL ) {
-	mdb_env_close( dbh->h_env );
-	dbh->h_env = NULL;
+        mdb_env_close( dbh->h_env );
+        dbh->h_env = NULL;
     }
     free( dbh );
 }
-/* vim: set softtabstop=4 shiftwidth=4 noexpandtab :*/
+
+/* vim: set softtabstop=4 shiftwidth=4 expandtab :*/


vboot_reference/futility: Inline get_host_wp()

writeprotect still requires sub-processing flashrom as
libflashrom currently lacks a API to perform this task.
Therefore simplify the remaining sub-process logic for
just this purpose.

BUG=b:203715651
BRANCH=none
TEST=cros deploy to nocturne and ran:
 `/usr/sbin/chromeos-firmwareupdate --mode=recovery --wp=1`.
&& `$ cros_run_unit_tests --board nocturne --packages vboot_reference`.

Signed-off-by: Edward O'Callaghan <5ed2e9bf3d98d5f12a86c198971e1dafd1bbd008@google.com>
Change-Id: I11c0f89997e3f47e97444cc8186823fa536b8d5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3233704
Tested-by: Edward O'Callaghan <5ed2e9bf3d98d5f12a86c198971e1dafd1bbd008@chromium.org>
Commit-Queue: Edward O'Callaghan <5ed2e9bf3d98d5f12a86c198971e1dafd1bbd008@chromium.org>
Reviewed-by: Nikolai Artemiev <ae95c3c53a91f37eed715bc8c4b874a04007f68d@google.com>
Reviewed-by: Sam McNally <fa45cad00d68e10cba722214c28ca2497355b0cc@chromium.org>

--- futility/updater_utils.c
+++ futility/updater_utils.c
@@ -25,10 +25,6 @@

 #define COMMAND_BUFFER_SIZE 256
 #define FLASHROM_OUTPUT_WP_PATTERN "write protect is "
-
-enum flashrom_ops {
-	FLASHROM_WP_STATUS,
-};

 /* System environment values. */
 static const char * const STR_REV = "rev",
@@ -524,89 +520,6 @@
 	*need_prepare_ptr = need_prepare;

 	return ret;
-}
-
-/*
- * A helper function to invoke flashrom(8) command.
- * Returns 0 if success, non-zero if error.
- */
-static int host_flashrom(enum flashrom_ops op, const char *image_path,
-			 const char *programmer, int verbose,
-			 const char *section_name, const char *extra)
-{
-	char *command, *result;
-	const char *op_cmd, *dash_i = "-i", *postfix = "";
-	int r;
-
-	switch (verbose) {
-	case 0:
-		postfix = " >/dev/null 2>&1";
-		break;
-	case 1:
-		break;
-	case 2:
-		postfix = "-V";
-		break;
-	case 3:
-		postfix = "-V -V";
-		break;
-	default:
-		postfix = "-V -V -V";
-		break;
-	}
-
-	if (!section_name || !*section_name) {
-		dash_i = "";
-		section_name = "";
-	}
-
-	switch (op) {
-	case FLASHROM_WP_STATUS:
-		op_cmd = "--wp-status";
-		assert(image_path == NULL);
-		image_path = "";
-		/* grep is needed because host_shell only returns 1 line. */
-		postfix = " 2>/dev/null | grep \"" \
-			   FLASHROM_OUTPUT_WP_PATTERN "\"";
-		break;
-
-	default:
-		assert(0);
-		return -1;
-	}
-
-	if (!extra)
-		extra = "";
-
-	/* TODO(b/203715651): link with flashrom directly. */
-	ASPRINTF(&command, "flashrom %s %s -p %s %s %s %s %s", op_cmd,
-		 image_path, programmer, dash_i, section_name, extra,
-		 postfix);
-
-	if (verbose)
-		INFO("Executing: %s\n", command);
-
-	if (op != FLASHROM_WP_STATUS) {
-		r = system(command);
-		free(command);
-		if (r)
-			ERROR("Error code: %d\n", r);
-		return r;
-	}
-
-	result = host_shell(command);
-	strip_string(result, NULL);
-	free(command);
-	VB2_DEBUG("wp-status: %s\n", result);
-
-	if (strstr(result, FLASHROM_OUTPUT_WP_ENABLED))
-		r = WP_ENABLED;
-	else if (strstr(result, FLASHROM_OUTPUT_WP_DISABLED))
-		r = WP_DISABLED;
-	else
-		r = WP_ERROR;
-	free(result);
-	return r;
 }

 // global to allow verbosity level to be injected into callback.
@@ -751,8 +664,32 @@
 /* Helper function to return write protection status via given programmer. */
 enum wp_state host_get_wp(const char *programmer)
 {
-	return host_flashrom(FLASHROM_WP_STATUS, NULL, programmer, 0, NULL,
-			     NULL);
+	char *command, *result;
+	const char *postfix;
+	int r;
+
+	/* grep is needed because host_shell only returns 1 line. */
+	postfix = " 2>/dev/null | grep \"" FLASHROM_OUTPUT_WP_PATTERN "\"";
+
+
+	/* TODO(b/203715651): link with flashrom directly. */
+	ASPRINTF(&command, "flashrom --wp-status -p %s %s", programmer, postfix);
+
+	/* invokes flashrom(8) with non-zero result if error. */
+	result = host_shell(command);
+	strip_string(result, NULL);
+	free(command);
+	VB2_DEBUG("wp-status: %s\n", result);
+
+	if (strstr(result, FLASHROM_OUTPUT_WP_ENABLED))
+		r = WP_ENABLED;
+	else if (strstr(result, FLASHROM_OUTPUT_WP_DISABLED))
+		r = WP_DISABLED;
+	else
+		r = WP_ERROR;
+	free(result);
+
+	return r;
 }

 /* Helper function to return host software write protection status. */


simulation.c has gp2 and gp1 working. It plots first gp2 and then gp1

--- simulation.c
+++ simulation.c
@@ -1,24 +1,30 @@
 //
-//  test1.c
+//  sim8.c
 //
 //
-//  Created by Arthur Romero on 6/5/15.
+//  Created by Arthur Romero on 7/10/15.
 //
 //
-
+#include <stdio.h>
+#include <stdlib.h>
 #include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
 #include <complex.h>
-#include "simulation.h"
-
-
-
-
+#include <complex>
+#include <ccomplex>
+#include "complex.h"
+
+
+#include "TCanvas.h"
+#include "TGraph.h"
+#include "TApplication.h"
+#include "TROOT.h"
+
+
+#include "SimplePlot.hh"

 //global variables:
+

 double e_charge = 0.00000000000000000016021765;
 double e_mass = 0.00000000000000000000000000000091093819;
@@ -80,17 +86,25 @@
 double sinc(double x);//prototype

-
-void gp0(double z,double r0,double el0, double w0);//prototype
-
 void gp1(double z,double r0,double el0, double w0);//prototype

-void gp2(double z12,double z23, double mytheta, double el1x, double w1x, double r1x, double el1y, double w1y, double r1y, double G2_x);//prototype
+void gp2(double z12,double z23, double mytheta, double el1x, double w1x, double r1x, double el1y, double w1y, double r1y, double G2_x); // prototype

 int x2pnts(float *arr, int r, int value);//prototype

-int main( void )
+
+
+
+
+
+
+
+
+
+
+
+int main( )
 {
     double lam = pow((150)/(4000),1/2)*pow(10,-10);// double lam = 1.936E-10//

@@ -120,13 +134,9 @@
     double r1;
     double el1;
     double el2;
-
-
-    float fc;
-    float ph;
-    float ex;
-    int j;
-
+    double *x1;
+
+

     w1=w(G1_z,r0,el0,w0);//gp1
@@ -140,266 +150,23 @@
     //printf("the value of el1 is:  %.12f\n",el1); //matches with Mathematica value of el1

     el2 = el(zstart-G1_z+zres*100, r1, el1, w1);//gp2
-    // printf("the value of el2 is:  %.12f\n",el2);// matches with mathematica value
-
-
-
-
-    float ReT[41][2]={{0}}; //Real Transpose
-    for (int i=0; i<=41; i++) {
-        ReT[i][0]=i-20;
-
-    }
-
-
-
-    float ImT[41][2]={{0}};//Imaginary Transpose
-    for (int i=0; i<=41; i++) {
-        ImT[i][0]=i-20;
-
-    }
-
-
-
-
-    if (beta>=0){
-
-
-
-        xmin= width*(1/res - cos(beta)/2);
-        if (beta<=alpha) {
-            xmax=(width*cos(beta))/2-width/res;
-        }
-        else
-        {
-            xmax=width*cos(beta)/2-width/res+thick*(tan(alpha)-tan(beta));
-        }
-    }
-    else
-    {
-        xmax = (width*cos(beta)/2)-width/res;
-        if (fabsl(beta)<=alpha) {
-            xmin = -((width*cos(beta))/2)+width/res;
-        }
-        else
-        {
-            xmin = -((width*cos(beta))/2)+width/res - thick*(tan(alpha)-tan(beta));
-        }
-
-    }
-    // printf("the value of xmax is: %.12Lf \n",xmax);// same value in mathematica
-    // printf("the value of xmin is: %.12Lf \n",xmin);//same value in mathematica
-    //printf("the value of p is: %.12Lf \n",p);
-    //printf("the value of width is: %.12f \n",width);
-
-
-
-
-    for(int n=-20;n<=20;n++)
-    {
-        for(ex=xmin; ex<xmax; ex+=width/res)
-        {
-            fc = 2*pi*n*ex/d;
-
-            //printf("the value of fc is: %f and n is: %d and ex is %.12f \n",fc,n,ex); //same value in mathematica
-
-            ph = -width*thick*chargeratio*pow(e_charge,2)*(2*pi*Coulomb/Plancks)/(vel*(.25*pow(width,2)-pow(ex,2)));
-
-            //printf("the value of ph is: %f and n is: %d and ex is %.12f \n",ph,n,ex); //same value in mathematica
-
-
-            j=n+20;
-
-            ReT[j][1] += cos(ph+fc);
-            ImT[j][1] += sin(ph+fc);
-
-        }
-
-
-
-        // for(j=0;j<=41;j++){
-
-        //ReT[j][1] += cos(ph+fc);
-        //ImT[j][1] += sin(ph+fc);
-
-        //printf("the value of ReT is: %f and j is: %d \n",ReT[j][1],j);
-        //printf("the value of ImT is: %f and j is: %d \n",ImT[j][1],j);
-        //  }
-
-
-
-
-    }
-
-
-    // testing if the results match with methematica
-    for (int i=0; i<=40; i++) {
-        //  printf("value of ReT is: %f and j is: %d \n",ReT[i][1],(i-20));////same value in mathematica
-        // printf("value of ImT is: %f and j is: %d \n",ImT[i][1],(i-20));////same value in mathematica
-
-
-        ReT[i][1] = ReT[i][1]/res;
-        ImT[i][1] = ImT[i][1]/res;
-
-        //printf("value of ReT is: %f and j is: %d \n",ReT[i][1],(i-20));////same value in mathematica
-        //printf("value of ImT is: %f and j is: %d \n",ImT[i][1],(i-20));////same value in mathematica
-
-    }
-
-    // printf("the value of ReT is: %f and j is: %d \n",ReT[j][1],j);
-
-
-
-
-
-
-
-
-
-
-
-
-    /////////////////////////////////////----Set spatial limits of simulation and initialize waves containg simulation outputs-----//////////////////////////////////////////////
-
-
-
-
-
-
-    float fmap[150][300];    //
-
-    for (int i=0; i<=150; i++) {
-        for (int j=0; j<=300; j++) {
-
-            fmap[i][j]=0;
-
-            //printf("the value of fmap1 is: %f , i = %d \t , j = %d\n",fmap1[i][j],i,j); /// fmap is an array of 150 rows and 300 columns
-        }
-    }
-
-
-
-    float izx[300][300];
-
-    for (int i=0; i<=300; i++) {
-        for (int j=0; j<=300; j++) {
-
-            izx[i][j]=0;
-
-            //printf("the value of izx is: %f , i = %d \t , j = %d\n",izx[i][j],i,j); // izx is an array of 300 rows and 300 columns
-        }
-    }
-
-
-
-
-
-
-    double ix[300][2]={0};
-
-
-    for (int i=0; i<=300; i++) {
-        ix[i][0]= xstart+(i-1)*((xend-xstart)/(xpnts-1));
-        //printf("the values of ix[i] and i are: %f\t and %d\n",ix[i][0],i);//different format, but same values as in the Mathematica code
-    }
-
-
-    double g1[600][2]={0}; // instead of 0, it should be NaN // I do not know the difference
-
-
-    for (int i=0; i<=600; i++) {
-        g1[i][0]= xstart+(i-1)*((xend-xstart)/(2*xpnts-1));
-        //printf("the valueof g1[i][0] at i, %f\t is: %d\n",g1[i][0],i); //different format, but same values as in the Mathematica code
-    }
-
-
-
-
-    double g2[600][2]={0}; // instead of 0, it should be NaN // I do not know the difference
-
-
-    for (int i=0; i<=600; i++) {
-        g2[i][0]= xstart+(i-1)*((xend-xstart)/(2*xpnts-1));
-        //printf("the valueof g2[i][0] at i, %f\t is: %d\n",g2[i][0],i);//different format, but same values as in the Mathematica code
-    }
-
-
-
-    double vis[300][2]={0}; //
-
-
-    for (int i=0; i<=300; i++) {
-        vis[i][0]= (zstart-G1_z)+(i-1)*((zend-zstart)/(zpnts-1));
-        //printf("the valueof vis[i][0] at i, %f\t is: %d\n",vis[i][0],i);//different format, but same values as in the Mathematica code
-    }
-
-
-
-
-
-    //lacks ixy
-
-    ////////////////////////////////////////////////////////////////
-
-
-    ///////Calculating GSM parameter at first grating://///
-
-
-    //////////////////////////////////////////////////
-
-
-    //gp0:
-
-
-
-
-    //gp0(zstart+zres*1,r0,el0,w0);
-
-
-
-
-    //}
-    /////////////////////////////////////////////////
-    //gp1:
-
-
-
-
-
-    gp1(zstart - G1_z + zres*100,r1,el1,w1);
-
-
-
-
-
-
-
-
-
-    ///////////////////////////////////////////////////////
-    //gp2:
-
-
-
-
-
-
-
-
-
-   //gp2(G2_z-G1_z,zstart+0*zres,theta,el1,w1,r1,el1,w1,r1,G2_x);
-
-    //printf("the values of z12,z23,theta,el1,w1,r1,and G2_x are: %f \t %f \t %0.15f \t %0.15f \t %0.15f \t %f \n",G2_z-G1_z,zstart+0*zres,theta,el1,w1,r1);
-    //printf("the value of G2_x is : %0.15f \n",G2_x);
-
-    // input values are the same.
-
-
-    return 0;
-
+     //printf("the value of el2 is:  %.12f\n",el2);// matches with mathematica value
+
+
+
+     gp2(G2_z-G1_z,zstart+0*zres,theta,el1,w1,r1,el1,w1,r1,G2_x);
+
+     gp1(zstart - G1_z + zres*100,r1,el1,w1);
+    // printf("the value of el2 is:  %.12f\n",el2);
+
+
+
+
+

 }
+

@@ -523,30 +290,6 @@

 }
-
-
-
-
-void gp0 (double z,double r0,double el0, double w0)
-{
-    double w1;
-    double ix[300][2]={0};
-
-
-    for (int i=0; i<300; i++) {
-        ix[i][0]= xstart+(i-1)*((xend-xstart)/(xpnts-1));
-        ix[i][1]=exp(-pi*pow((ix[i][0]/w1),2));
-        //printf("the values of ix[i] and i are: %f\t and %d\n",ix[i][1],i);//
-
-    }
-
-
-}
-
-
-
-
-

 void gp1(double z,double r0,double el0, double w0)
 {
@@ -566,7 +309,7 @@
     double el1;
     double el2;

-
+
     double zres = (zend-zstart)/zpnts;

@@ -581,7 +324,7 @@
     float ph;
     float ex;
     int j;
-     FILE *out_file1 = fopen("ploting_gp1.xls","w+");
+

     w1=w(G1_z,r0,el0,w0);
@@ -769,15 +512,38 @@

         }
-         printf("the values of ix[i][1] are:  %0.19f \t %d \n",ix[i][1],i);//
-         fprintf(out_file1, "%.19f\t%.19f\t%d\n", ix[i][0], ix[i][1],i);
-    }
-
+        //printf("the values of ix[i][1] are:  %0.19f \t %d \n",ix[i][1],i);//
+
+    }
+
+
+    double ix1[300]={0};
+    double ix2[300]={0};
+
+
+
+    for (int i=0; i<300; i++) {
+        for (int j=0; j<2; j++) {
+            if (j==0) {
+                ix1[i]=ix[i][j];
+            }
+            if (j==1) {
+                ix2[i] = ix[i][j];
+            }
+        }
+    }
+
+
+    SimplePlot::graph("gp1 graph",ix1,ix2,300);

 }
+
+
+
+

@@ -790,7 +556,7 @@

-
+
     double res = 1000;
     double eta = width/d;
     double vel = pow(2*energy*e_charge/e_mass,1/2);
@@ -820,7 +586,8 @@

     double lim =5;

-    double complex coef =0;
+    double _Complex coef;
+    //double complex coef;
     double dn = 0;
     double dm =0;
     double m=0;
@@ -831,7 +598,9 @@
     int d5=0;
     double test1=0;

-    FILE *out_file2 = fopen("ploting_gp2.xls","w+");
+
+
+

     // printf("the values of theta, d1,d2 and z13 are:   %0.15f \t %0.15f \t %0.15f \t %0.15f \n",theta,d1,d2,z13);// the values match with the mathematica values.
@@ -839,7 +608,7 @@

     double el3x = el(z13, r1x, el1x, w1x);//G2z - G1z + zstart + 0*zres, r1, el1, w1
-   // printf("the value of el3x is: %0.15f\n",el3x);//value matches with mathematica
+    // printf("the value of el3x is: %0.15f\n",el3x);//value matches with mathematica

     double w3x = w(z13,r1x,el1x,w1x);
@@ -847,15 +616,15 @@

     double v3x = v(z13,r1x,el1x,w1x);
-   // printf("the value of v3x is: %0.15f\n",v3x);//value matches with mathematica
+    // printf("the value of v3x is: %0.15f\n",v3x);//value matches with mathematica

     double el3y = el(z13,r1y,el1y, w1y);
-   // printf("the value of el3y is: %0.15f\n",el3y);//value matches with mathematica
+    // printf("the value of el3y is: %0.15f\n",el3y);//value matches with mathematica

     double w3y = w(z13,r1y,el1y,w1y);
-   // printf("the value of w3y is: %0.15f\n",w3y);//value matches with mathematica
+    // printf("the value of w3y is: %0.15f\n",w3y);//value matches with mathematica

     double v3y = v(z13,r1y,el1y,w1y);
@@ -882,7 +651,7 @@
         //printf("value of ImT is: %f and j is: %d \n",ImT[i][1],(i-20)); ok

     }
-
+

     if (beta>=0){
@@ -911,7 +680,7 @@

     }
     //printf("the value of xmax is: %.12Lf \n",xmax);// same value in mathematica
-     //printf("the value of xmin is: %.12Lf \n",xmin);//same value in mathematica
+    //printf("the value of xmin is: %.12Lf \n",xmin);//same value in mathematica

     //printf("the value of width is: %.12f \n",width);

@@ -928,7 +697,7 @@

             ph = -width*thick*chargeratio*pow(e_charge,2)*(2*pi*Coulomb/Plancks)/(vel*(.25*pow(width,2)-pow(ex,2)));

-           // printf("the value of ph is: %f and n is: %d and ex is %.12f \n",ph,n,ex); //same value in mathematica
+            // printf("the value of ph is: %f and n is: %d and ex is %.12f \n",ph,n,ex); //same value in mathematica

@@ -969,7 +738,7 @@

     }

-     //printf("the value of ReT is: %f and j is: %d \n",ReT[j][1],j);
+    //printf("the value of ReT is: %f and j is: %d \n",ReT[j][1],j);

@@ -983,7 +752,7 @@

     for (int i=0; i<300; i++) {
         ix[i][0]= xstart+(i-1)*((xend-xstart)/(xpnts-1));
-         //printf("the values of ix[i] and i are: %f\t \t %d\n",ix[i][0],i);//different format, but same values as in the Mathematica code
+        //printf("the values of ix[i] and i are: %f\t \t %d\n",ix[i][0],i);//different format, but same values as in the Mathematica code
     }

@@ -1001,136 +770,156 @@
             for (int m2=-lim; m2<=lim; m2++) {
                 for (int n1=-lim; n1<=lim; n1++) {
                     for (int n2=-lim; n2<=lim; n2++) {
-
-
+
+
                         dn =n1-n2;
                         n = ((double)(n1+n2))/2;
                         dm = m1-m2;
                         m = ((double)(m1+m2))/2;
-
-
+
+
                         a = (x2pnts((float *)ReT, r, m1));
                         b = (x2pnts((float *)ReT, r, m2));
                         c = (x2pnts((float *)ReT, r, n1));
                         d5 = (x2pnts((float *)ReT, r, n2));
-
-
-
+
+
+
                         if (test1==1)
                         {
-
-                            coef = sinc(eta1*pi*m1)+ 0*I;
-                            coef = coef*(sinc(eta1*pi*m2+ 0*I));
+
+                            coef = sinc(eta1*pi*m1)+ 0*_Complex_I;
+                            coef = coef*(sinc(eta1*pi*m2+ 0*_Complex_I));
                             //printf("the value of coef is: %f \n", coef);
-
+
                         }
                         else
                         {
-
-
-                            coef = ReT[a][1]+ImT[a][1]*I;
+
+
+                            coef = ReT[a][1]+ImT[a][1]*_Complex_I;
                             //printf("the value of coef and a are: %0.15f \t %0.15fi \t %d \n", crealf(coef), cimagf(coef), a);
                             //printf("the value of coef and a are:%0.15f \t %0.15fi \t %d \n", cimagf(coef),ImT[a][1], a);
-
-                            coef = coef*((ReT[b][1]-ImT[b][1]*I));
+
+                            coef = coef*((ReT[b][1]-ImT[b][1]*_Complex_I));
                             //printf("the value of coef is: %0.15f \t %0.15fi \t %d \n", ReT[b][1], ImT[b][1], b);
                         }
-
-
-
-
-                        coef = coef*(ReT[c][1] + ImT[c][1]*I);
-
+
+
+
+
+                        coef = coef*(ReT[c][1] + ImT[c][1]*_Complex_I);
+
                         //printf("the value of coef is: %f \t %f \n", creal(coef), cimag(coef));
-
-                        coef = coef*(ReT[d5][1] + ImT[d5][1]*I);
-
+
+                        coef = coef*(ReT[d5][1] + ImT[d5][1]*_Complex_I);
+
                         //printf("the value of coef is: %0.10f \t %0.10f \n", creal(coef), cimag(coef));
-
-
-                        coef=coef*(cexp(-pi*cpow(((dn*csin(theta)*lambda*(z23))/(d2*el3y)),2)));
-
+
+
+                        coef=coef*(exp(-pi*pow(((dn*sin(theta)*lambda*(z23))/(d2*el3y)),2)));
+
                         //printf("the value of coef is: %0.10f \t %0.10f \n", creal(coef), cimag(coef));
-
-
-                        coef=coef*(cexp(-pi*cpow((lambda*z23*(dn*ccos(theta)+dm*z13/z23)/(d1*el3x)),2)));
-
+
+
+                        coef=coef*(exp(-pi*pow((lambda*z23*(dn*cos(theta)+dm*z13/z23)/(d1*el3x)),2)));
+
                         //printf("the value of coef is: %0.19f \t %0.19fi \n", crealf(coef), cimagf(coef));// results match with mathematica's!
-
-
-
-
-
-
-
-
-                        if (((creal(coef))>=cutoff) || ((cimag(coef))>=cutoff)) {
+
+
+
+
+
+
+
+
+                        if (((__real__ coef)>=cutoff) || ((__imag__ coef)>=cutoff)) {
                             //printf("the value of coef is: %0.10f \t %0.10fi \n", crealf(coef), cimagf(coef));//results match with mathematica's!
-
+
                             phi = dn*n*(1-z23/v3x)*pow((cos(theta)),2) + dn*n*(1-z23/v3y)*pow((sin(theta)),2) + dn*m*(1-z13/v3x)*cos(theta);
                             //phi = dn*n*(1-z23/v3x)+ dn*m*(1-z13/v3x)*cos(theta);
-
+
                             //printf("the values of phi is: %f \n", phi);
-
-
+
+
                             phi = phi +(dm*n*(1-z13/v3x)*cos(theta) + dm*m*(z13/z23)*(1-z13/v3x));
                             //printf("the values of phi is: %f \n", phi);
-
+
                             phi = phi*(2*pi*lambda*z23/(pow(d1,2)));
                             //printf("the values of phi is: %f \n", phi);
-
+
                             phi = phi - (2*pi*dn*G2_x/d2);
-
-
-
-
-
-                                phix[i][1] = ((phi-(2*pi*(phix[i][0])/d2)*(dn*cos(theta)*(1-z23/v3x) + dm*(1-z13/v3x))));
-
-
-                             //printf("the values of phix[i][1] is: %f \t %d \n", phix[i][1], i);//values apparently are the same as in mathematica(zeros)
-
-
-
-
-                            ix[i][1] = ix[i][1] + (((creal(coef)*cos(phix[i][1]) - cimag(coef)*sin(phix[i][1]))*exp(-pi*pow(((phix[i][0]-(lambda*z23/d1)*(n*cos(theta)+m*(z13/z23)))/w3x),2))));
-
-
-
-
-                            }
-
+
+
+
+
+
+                            phix[i][1] = ((phi-(2*pi*(phix[i][0])/d2)*(dn*cos(theta)*(1-z23/v3x) + dm*(1-z13/v3x))));
+
+
+                            //printf("the values of phix[i][1] is: %f \t %d \n", phix[i][1], i);//values apparently are the same as in mathematica(zeros)
+
+
+
+
+                            ix[i][1] = ix[i][1] + ((((__real__ coef)*cos(phix[i][1]) - (__imag__ coef)*sin(phix[i][1]))*exp(-pi*pow(((phix[i][0]-(lambda*z23/d1)*(n*cos(theta)+m*(z13/z23)))/w3x),2))));
+
+
+
+
                         }
-
-
-
-
-
-
-
-
-
-
-
-
-
+
                     }
-
+
+
+
+
+
+
+
+
+
+
+
+
+
                 }
-
+
             }
-        printf("the values of ix[i][1] are:  %0.19f \t %d \n",ix[i][1],i);// the results match with mathematica's!!
-        fprintf(out_file2, "%.19f\t%.19f\n", ix[i][0], ix[i][1]);
-
-        }
-
-
-
-
-
-    }
-
-
-
-
-
+
+        }
+       //printf("the values of ix[i][1] are:  %0.19f \t %d \n",ix[i][1],i);// the results match with mathematica's!!
+
+
+    }
+
+
+    double ix3[300]={0};
+    double ix4[300]={0};
+
+
+
+    for (int i=0; i<300; i++) {
+        for (int j=0; j<2; j++) {
+            if (j==0) {
+                ix3[i]=ix[i][j];
+            }
+            if (j==1) {
+                ix4[i] = ix[i][j];
+            }
+        }
+    }
+
+
+    SimplePlot::graph("gp2 graph",ix3,ix4,300);
+
+
+
+
+
+}
+
+
+
+
+


Host buffer accessor now passes indices in the subscript operator.

--- sycl-gtx/implementation/specification/accessor/buffer.h
+++ sycl-gtx/implementation/specification/accessor/buffer.h
@@ -91,19 +91,38 @@
 	}
 };

+#define SYCL_ACCESSOR_HOST_REF_CONSTRUCTOR()									\
+	using acc_t = accessor_<DataType, dimensions, mode, access::host_buffer>;	\
+	friend class acc_t;															\
+	friend class accessor_host_ref;												\
+	acc_t* acc;																	\
+	range<3> rang;																\
+	accessor_host_ref(acc_t* acc, range<3> range)								\
+		: acc(acc), rang(range) {}												\
+	accessor_host_ref()															\
+		: accessor_host_ref(nullptr, empty_range<3>()) {}
+
 template <int level, typename DataType, int dimensions, access::mode mode>
 class accessor_host_ref {
 protected:
 	using Lower = accessor_host_ref<dimensions - 1, DataType, dimensions, mode>;
-	using acc_t = accessor_<DataType, dimensions, mode, access::host_buffer>;
-	friend class acc_t;
-	friend class accessor_host_ref;
-	acc_t* acc;
-	accessor_host_ref(acc_t* acc = nullptr)
-		: acc(acc) {}
+	SYCL_ACCESSOR_HOST_REF_CONSTRUCTOR();
 public:
 	Lower operator[](int index) {
-		return Lower(acc);
+		auto rang_copy = rang;
+		rang_copy[dimensions] = index;
+		return Lower(acc, rang_copy);
+	}
+};
+
+template <typename DataType, int dimensions, access::mode mode>
+class accessor_host_ref<1, DataType, dimensions, mode> {
+protected:
+	SYCL_ACCESSOR_HOST_REF_CONSTRUCTOR();
+public:
+	DataType operator[](int index) {
+		// TODO
+		return 0;
 	}
 };

@@ -111,6 +130,8 @@
 	public accessor_buffer<DataType, dimensions>,
 	public accessor_host_ref<dimensions, DataType, dimensions, (access::mode)mode>
 {
+	template <int level, typename DataType, int dimensions, access::mode mode>
+	friend class accessor_host_ref;
 public:
 	SYCL_BUFFER_CONSTRUCTORS({
 		acc = this;


ncd/modules/regex_match: fix uninitialized variable warning

--- ncd/modules/regex_match.c
+++ ncd/modules/regex_match.c
@@ -260,7 +260,7 @@
     while (in_pos < in_len) {
         // find first match
         int have_match = 0;
-        size_t match_regex;
+        size_t match_regex = 0; // to remove warning
         regmatch_t match = {0, 0}; // to remove warning
         for (size_t j = 0; j < num_regex; j++) {
             regmatch_t this_match;


cleanup

cleanup

--- cstool/cstool_x86.c
+++ cstool/cstool_x86.c
@@ -1,4 +1,3 @@
-/* Second-Best Disassembler Engine */
 /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */

 #include <stdio.h>


vout: gl: don't handle Android opaque fmt

--- modules/video_output/gl.c
+++ modules/video_output/gl.c
@@ -99,6 +99,10 @@
 static int Open (vlc_object_t *obj)
 {
     vout_display_t *vd = (vout_display_t *)obj;
+
+    if (vd->fmt.i_chroma == VLC_CODEC_ANDROID_OPAQUE)
+        return VLC_EGENERIC;
+
     vout_display_sys_t *sys = malloc (sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;


renamed super_block.c to open_file.c

renamed super_block.c to open_file.c

--- super_block.c
+++ super_block.c
@@ -1,59 +0,0 @@
-//super_block.c
-//Sortafine Industries
-//Compile with: gcc -Wall -std=c99 super_block.c -lm blockio.c
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "blockio.h"
-#define BUFFER_SIZE 512
-#define BITMAP_BUFF 512
-
-// Function Declarations //
-int put_file(int file_type, char* name);
-
-int set_refrence_count(int fd, int ref);
-	// get_block
-	// put_block
-int get_refrence_count(int fd, int* ref_buf);
-	// get_block
-
-void get_file(void);
-
-void set_fd(void);
-	// get_block
-	// put_block
-
-void get_fd(void);
-	// get_block
-
-// Global Variables //
-short int* super_blk_buf = NULL;
-int* disk_bitmap = NULL;
-int* reference_count=NULL;
-int* fd_table=NULL;
-char* buff = NULL;
-
-
-// Function Definitions //
-
-int set_refrence_count(int fd, int ref){
-	reference_count[fd] = ref;
-}
-	// get_block
-	// put_block
-int get_reference_count(int fd, int* ref_buf){
-	&ref_buf=referenc_count[fd];
-}
-int put_file(int file_type, char* name){
-	int space = get_empty_blk();
-	int** I_node_buff = get_inode_table();
-	int**
-} // Not finished yet!
-	// get_empty_blk
-	// put_inode_table
-	// put_block
-int get_file(void){
-
-	return -1;
-}
-	// get_block


Add more features that may be disabled

Add more features that may be disabled

Have a look at the directories in crypto/, I found reason to add
checks on CMAC and HMAC.  This might be completely irrelevant, but I
prefered covering too much than not enough.

Reviewed-by: Stephen Henson <9ce5770b3bb4b2a1d59be2d97e34379cd192299f@openssl.org>

--- apps/openssl.c
+++ apps/openssl.c
@@ -735,6 +735,9 @@
 #ifdef OPENSSL_NO_CAST
     BIO_puts(bio_out, "CAST\n");
 #endif
+#ifdef OPENSSL_NO_CMAC
+    BIO_puts(bio_out, "CMAC\n");
+#endif
 #ifdef OPENSSL_NO_CMS
     BIO_puts(bio_out, "CMS\n");
 #endif
@@ -767,6 +770,9 @@
 #endif
 #ifdef OPENSSL_NO_GOST
     BIO_puts(bio_out, "GOST\n");
+#endif
+#ifdef OPENSSL_NO_HMAC
+    BIO_puts(bio_out, "HMAC\n");
 #endif
 #ifdef OPENSSL_NO_IDEA
     BIO_puts(bio_out, "IDEA\n");


Add ccnx as a recognized prefix, and change module description to use CCNx instead of CCN

--- apps/vlc/ccn.c
+++ apps/vlc/ccn.c
@@ -56,8 +56,8 @@
 static void *ccn_event_thread(vlc_object_t *p_this);

 vlc_module_begin();
-    set_shortname(N_("CCN"));
-    set_description(N_("CCN input"));
+    set_shortname(N_("CCNx"));
+    set_description(N_("CCNx input"));
     set_category(CAT_INPUT);
     set_subcategory(SUBCAT_INPUT_ACCESS);
     add_integer("ccn-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL,
@@ -65,6 +65,7 @@
     change_safe();
     set_capability("access", 0);
     add_shortcut("ccn");
+    add_shortcut("ccnx");
     set_callbacks(CCNOpen, CCNClose);
 vlc_module_end();


try to find common mode from preferred modes

--- xrandrd.c
+++ xrandrd.c
@@ -71,14 +71,19 @@
 	return 0;
 }

-int has_wxh(XRRScreenResources *sr, XRROutputInfo *oi, unsigned int width, unsigned int height)
-{
+int has_wxh_preferred(XRRScreenResources *sr, XRROutputInfo *oi, unsigned int width, unsigned int height)
+{
+	unsigned int last_w = -1, last_h = -1;
 	for (int i = 0; i < oi->nmode; i++) {
 		unsigned int w, h;
 		if (!get_wxh(sr, oi->modes[i], &w, &h))
 			return 0;
+		if (last_w < w && last_h < h)
+			return 0;
 		if (w == width && h == height)
 			return 1;
+		last_w = w;
+		last_h = h;
 	}
 	return 0;
 }
@@ -100,7 +105,7 @@
 	return counter;
 }

-int common_mode(Display *display, Window window, unsigned int *width, unsigned int *height)
+int preferred_common_mode(Display *display, Window window, unsigned int *width, unsigned int *height)
 {
 	XRRScreenResources *sr = XRRGetScreenResources(display, window);
 	XRROutputInfo **ois = malloc(sizeof(XRROutputInfo *) * sr->noutput);
@@ -116,16 +121,21 @@
 	}
 	XRROutputInfo *first = first_connected(sr, ois);
 	int counter = 0;
+	unsigned int last_w = -1, last_h = -1;
 	for (int k = 0; k < first->nmode; k++) {
 		counter = 1;
 		if (!get_wxh(sr, first->modes[k], width, height))
 			exit(1);
+		if (last_w < *width && last_h < *height)
+			return 0;
+		last_w = *width;
+		last_h = *height;
 		for (int j = 0; j < sr->noutput; j++) {
 			if (ois[j]->connection != RR_Connected)
 				continue;
 			if (ois[j] == first)
 				continue;
-			if (has_wxh(sr, ois[j], *width, *height))
+			if (has_wxh_preferred(sr, ois[j], *width, *height))
 				counter++;
 		}
 		if (num == counter)
@@ -190,7 +200,7 @@
 void lets_rock(Display *display, Window window)
 {
 	unsigned int width, height;
-	if (common_mode(display, window, &width, &height)) {
+	if (preferred_common_mode(display, window, &width, &height)) {
 		fprintf(stderr, "xrandrd: setting common mode: %dx%d\n", width, height);
 		set_mode(display, window, width, height);
 	} else {


Remove copy constructor for AuthenticationInfo

--- src/cpp/rtps/security/SecurityManager.h
+++ src/cpp/rtps/security/SecurityManager.h
@@ -147,14 +147,6 @@
                         change_sequence_number_(SequenceNumber_t::unknown()),
                         event_(nullptr) {}

-                    AuthenticationInfo(const AuthenticationInfo& auth) :
-                        identity_handle_(auth.identity_handle_),
-                        handshake_handle_(auth.handshake_handle_),
-                        auth_status_(auth.auth_status_),
-                        expected_sequence_number_(auth.expected_sequence_number_),
-                        change_sequence_number_(auth.change_sequence_number_),
-                        event_(auth.event_) {}
-
                     AuthenticationInfo(AuthenticationInfo&& auth) :
                         identity_handle_(std::move(auth.identity_handle_)),
                         handshake_handle_(std::move(auth.handshake_handle_)),
@@ -174,6 +166,10 @@
                     SequenceNumber_t change_sequence_number_;

                     HandshakeMessageTokenResent* event_;
+
+                private:
+
+                    AuthenticationInfo(const AuthenticationInfo& auth) = delete;
             };

             struct EmptyDelete


Largely finished Control connection set-up.

git-svn-id: a387e899ed10e03ab636af3ac21b4488e15ce2f7@87 a2d82226-602c-0410-bba7-e51b83dd10d2

--- owampd/owampd.c
+++ owampd/owampd.c
@@ -14,6 +14,9 @@
 #define DEFAULT_IP_TO_CLASS_FILE 	"ip2class.conf"
 #define DEFAULT_CLASS_TO_LIMITS_FILE 	"class2limits.conf"
 #define DEFAULT_PASSWD_FILE 		"owamp_secrets.conf"
+
+#define CTRL_ACCEPT 0
+#define CTRL_REJECT 1

 const char *DefaultConfigFile = DEFAULT_CONFIG_FILE;
 char *ConfigFile = NULL;
@@ -157,9 +160,12 @@
 }

 void
-random_byte(char *ptr)
-{
-	*(u_int8_t *)ptr = random() / (RAND_MAX / 1<<8);
+random_bytes(char *ptr, int count)
+{
+	int i;
+	long scale = (RAND_MAX / 1<<8);
+	for (i = 0; i < count; i++)
+		*(u_int8_t *)(ptr+i) = random()/scale;
 }

 int
@@ -172,19 +178,37 @@
 	return 0;
 }

-void
-doit(int connfd)
+/*
+** Accept or reject the Control Connection request.
+** Code = CTRL_ACCEPT/CTRL_REJECT with the obvious meaning.
+*/
+void
+OWPServerOK(OWPControl ctrl, int sock, u_int8_t code, char* buf)
+{
+	bzero(buf, 32);
+	*(u_int8_t *)(buf+15) = code;
+	if (code == 0){ /* accept */
+		random_bytes(buf + 16, 16); /* Generate Server-IV */
+		OWPSetWriteIV(ctrl, buf + 16);
+	}
+	send_data(sock, buf, 32, 0);
+}
+
+/*
+** This function actually talks Control Protocol via the socket connfd.
+*/
+void
+doit(OWPControl ctrl, int connfd)
 {
 	char buf[MAX_MSG];
 	char *cur;
 	u_int32_t mode;
 	int i, r, encrypt;
 	u_int32_t mode_requested;
-	u_int8_t challenge[16], token[32], session_key[16], client_iv[32];
+	u_int8_t challenge[16], token[32], read_iv[16], write_iv[16];
 	u_int8_t kid[8]; /* XXX - assuming Stas will extend KID to 8 bytes */

 	/* Remove what's not needed. */
-	BYTE cv[128/8];
 	keyInstance keyInst;
 	cipherInstance cipherInst;

@@ -195,11 +219,8 @@
 	mode = htonl(get_mode());
 	*(int32_t *)(buf + 12) = mode; /* first 12 bytes unused */

-	/* generate random data for the last 16 bytes.
-	** We'll do it 16 times, one byte at a time, saving the result.
-	*/
-	for (i = 0; i < 16; i++)
-		random_byte(challenge + i);
+	/* generate 16 random bytes and save them away. */
+	random_bytes(challenge, 16);
 	bcopy(challenge, buf + 16, 16); /* the last 16 bytes */

 	/* Send server greeting. */
@@ -217,17 +238,18 @@
 	}

 	mode_requested = htonl(*(u_int32_t *)buf);
-
+	if (mode_requested & ~mode){ /* can't provide requested mode */
+		OWPServerOK(ctrl, connfd, CTRL_REJECT, buf);
+		close(connfd);
+		exit(0);
+	}
 	if (mode_requested & OWP_MODE_AUTHENTICATED){

 		/* Save 8 bytes of kid */
 		bcopy(buf + 4, kid, 8);

-		/* Decrypt the token and compare the 16 bytes of challenge */
-		bzero(client_iv, 16);
-
+		/* Fetch the shared secret and initialize the cipher. */
 		key = hash_fetch(passwd_hash, str2datum((const char *)kid));
-
 		r = makeKey(&keyInst, DIR_DECRYPT, 128, key->dptr);
 		if (TRUE != r) {
 			fprintf(stderr,"makeKey error %d\n",r);
@@ -239,19 +261,23 @@
 			exit(-1);
 		}

-		/* Decrypt two 16-byte blocks */
+		/* Decrypt two 16-byte blocks - save the result into token.*/
 		blockDecrypt(&cipherInst, &keyInst, buf + 12, 2*(16*8), token);

 		/* Decrypted challenge is in the first 16 bytes */
 		if (bcmp(challenge, token, 16)){
-			fprintf(stderr, "Authentication failed.\n");
+			OWPServerOK(ctrl, connfd, CTRL_REJECT, buf);
 			close(connfd);
-			exit(1);
+			exit(0);
 		}

 		/* Save 16 bytes of session key and 16 bytes of client IV*/
-		bcopy(token + 16, session_key, 16);
-		bcopy(buf + 44, client_iv, 16);
+		OWPSetSessionKey(ctrl, token + 16);
+		bcopy(buf + 44, read_iv, 16);
+
+		/* Apparently everything is ok. Accept the Control session. */
+		OWPServerOK(ctrl, connfd, CTRL_ACCEPT, buf);
+
 	}

 }
@@ -349,6 +375,7 @@
 	pid_t pid;
 	OWPErrSeverity out;
 	OWPContext ctx;
+	OWPControl ctrl; /* XXX - remember to initialize. */
 	OWPInitializeConfigRec cfg  = {
 		0,
 		0,
@@ -512,7 +539,7 @@
 		}

 		if (pid == 0) { /* child */
-			doit(connfd);
+			doit(ctrl, connfd);
 			exit(0);
 		}


Bluetooth: trivial: Correct types

Bluetooth: trivial: Correct types

Fix sparse warnigns below:
...
net/bluetooth/hci_sysfs.c:458:33: warning: cast to restricted __be32
net/bluetooth/hci_sysfs.c:458:47: warning: cast to restricted __be16
...

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

--- net/bluetooth/hci_sysfs.c
+++ net/bluetooth/hci_sysfs.c
@@ -444,8 +444,8 @@

 static void print_bt_uuid(struct seq_file *f, u8 *uuid)
 {
-	u32 data0, data4;
-	u16 data1, data2, data3, data5;
+	__be32 data0, data4;
+	__be16 data1, data2, data3, data5;

 	memcpy(&data0, &uuid[0], 4);
 	memcpy(&data1, &uuid[4], 2);


bridge: fix smatch warning / potential null pointer dereference

"New smatch warnings:
  net/bridge/br_multicast.c:1368 br_ip6_multicast_query() error:
    we previously assumed 'group' could be null (see line 1349)"

In the rare (sort of broken) case of a query having a Maximum
Response Delay of zero, we could create a potential null pointer
dereference.

Fixing this by skipping the multicast specific MLD Query parsing again
if no multicast group address is available.

Introduced by dc4eb53a996a78bfb8ea07b47423ff5a3aadc362
("bridge: adhere to querier election mechanism specified by RFCs")

Reported-by: Dan Carpenter <ff341aa343d564f9e53e9dcb6996be8c04859a66@oracle.com>
Signed-off-by: Linus Lüssing <1dd561f221e05f08425aa0351cbf66864fb4804d@web.de>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/bridge/br_multicast.c
+++ net/bridge/br_multicast.c
@@ -1372,6 +1372,8 @@

 		br_multicast_query_received(br, port, &br->ip6_other_query,
 					    &saddr, max_delay);
+		goto out;
+	} else if (!group) {
 		goto out;
 	}


netfilter: bridge: refactor conditional in br_nf_dev_queue_xmit

simpilifies followup patch that re-works brnf ip_fragment handling.

Signed-off-by: Florian Westphal <cef439e78636cdab99cd2923826c5065a0743e5b@strlen.de>
Signed-off-by: Pablo Neira Ayuso <707d14912bb250caf67dfe0ea4035681fbfc4f56@netfilter.org>


net: flow_dissector: add 802.1ad support

Same behavior than 802.1q : finds the encapsulated protocol and
skip 32bit header.

Signed-off-by: Eric Dumazet <312c7d941f03386814be517ffdb3e0eb6624e275@google.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/core/flow_dissector.c
+++ net/core/flow_dissector.c
@@ -65,6 +65,7 @@
 		nhoff += sizeof(struct ipv6hdr);
 		break;
 	}
+	case __constant_htons(ETH_P_8021AD):
 	case __constant_htons(ETH_P_8021Q): {
 		const struct vlan_hdr *vlan;
 		struct vlan_hdr _vlan;


Add a 'conj()' test for dense vector/dense vector subtractions ('dvecdvecsub')

--- blazetest/blazetest/mathtest/dvecdvecsub/OperationTest.h
+++ blazetest/blazetest/mathtest/dvecdvecsub/OperationTest.h
@@ -150,6 +150,7 @@
    template< typename T > void testScaledOperation   ( T scalar );
                           void testTransposeOperation();
                           void testAbsOperation      ();
+                          void testConjOperation     ();
                           void testEvalOperation     ();
                           void testSerialOperation   ();
                           void testSubvectorOperation();
@@ -296,6 +297,7 @@
    testScaledOperation( 2.0 );
    testTransposeOperation();
    testAbsOperation();
+   testConjOperation();
    testEvalOperation();
    testSerialOperation();
    testSubvectorOperation();
@@ -2770,6 +2772,288 @@

 //*************************************************************************************************
+/*!\brief Testing the conj dense vector/dense vector subtraction.
+//
+// \return void
+// \exception std::runtime_error Subtraction error detected.
+//
+// This function tests the conj vector subtraction with plain assignment, addition assignment,
+// subtraction assignment, and multiplication assignment. In case any error resulting from the
+// subtraction or the subsequent assignment is detected, a \a std::runtime_error exception is
+// thrown.
+*/
+template< typename VT1    // Type of the left-hand side dense vector
+        , typename VT2 >  // Type of the right-hand side dense vector
+void OperationTest<VT1,VT2>::testConjOperation()
+{
+#if BLAZETEST_MATHTEST_TEST_CONJ_OPERATION
+   if( BLAZETEST_MATHTEST_TEST_CONJ_OPERATION > 1 )
+   {
+      //=====================================================================================
+      // Conj subtraction
+      //=====================================================================================
+
+      // Conj subtraction with the given vectors
+      {
+         test_  = "Conj subtraction with the given vectors";
+         error_ = "Failed subtraction operation";
+
+         try {
+            initResults();
+            dres_   = conj( lhs_ - rhs_ );
+            sres_   = conj( lhs_ - rhs_ );
+            refres_ = conj( reflhs_ - refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<VT1,VT2>( ex );
+         }
+
+         checkResults<VT1,VT2>();
+
+         try {
+            initTransposeResults();
+            tdres_   = conj( tlhs_ - trhs_ );
+            tsres_   = conj( tlhs_ - trhs_ );
+            trefres_ = conj( treflhs_ - trefrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<TVT1,TVT2>( ex );
+         }
+
+         checkTransposeResults<TVT1,TVT2>();
+      }
+
+      // Conj subtraction with evaluated vectors
+      {
+         test_  = "Conj subtraction with evaluated vectors";
+         error_ = "Failed subtraction operation";
+
+         try {
+            initResults();
+            dres_   = conj( eval( lhs_ ) - eval( rhs_ ) );
+            sres_   = conj( eval( lhs_ ) - eval( rhs_ ) );
+            refres_ = conj( eval( reflhs_ ) - eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<VT1,VT2>( ex );
+         }
+
+         checkResults<VT1,VT2>();
+
+         try {
+            initTransposeResults();
+            tdres_   = conj( eval( tlhs_ ) - eval( trhs_ ) );
+            tsres_   = conj( eval( tlhs_ ) - eval( trhs_ ) );
+            trefres_ = conj( eval( treflhs_ ) - eval( trefrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<TVT1,TVT2>( ex );
+         }
+
+         checkTransposeResults<TVT1,TVT2>();
+      }
+
+
+      //=====================================================================================
+      // Conj subtraction with addition assignment
+      //=====================================================================================
+
+      // Conj subtraction with addition assignment with the given vectors
+      {
+         test_  = "Conj subtraction with addition assignment with the given vectors";
+         error_ = "Failed addition assignment operation";
+
+         try {
+            initResults();
+            dres_   += conj( lhs_ - rhs_ );
+            sres_   += conj( lhs_ - rhs_ );
+            refres_ += conj( reflhs_ - refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<VT1,VT2>( ex );
+         }
+
+         checkResults<VT1,VT2>();
+
+         try {
+            initTransposeResults();
+            tdres_   += conj( tlhs_ - trhs_ );
+            tsres_   += conj( tlhs_ - trhs_ );
+            trefres_ += conj( treflhs_ - trefrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<TVT1,TVT2>( ex );
+         }
+
+         checkTransposeResults<TVT1,TVT2>();
+      }
+
+      // Conj subtraction with addition assignment with evaluated vectors
+      {
+         test_  = "Conj subtraction with addition assignment with evaluated vectors";
+         error_ = "Failed addition assignment operation";
+
+         try {
+            initResults();
+            dres_   += conj( eval( lhs_ ) - eval( rhs_ ) );
+            sres_   += conj( eval( lhs_ ) - eval( rhs_ ) );
+            refres_ += conj( eval( reflhs_ ) - eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<VT1,VT2>( ex );
+         }
+
+         checkResults<VT1,VT2>();
+
+         try {
+            initTransposeResults();
+            tdres_   += conj( eval( tlhs_ ) - eval( trhs_ ) );
+            tsres_   += conj( eval( tlhs_ ) - eval( trhs_ ) );
+            trefres_ += conj( eval( treflhs_ ) - eval( trefrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<TVT1,TVT2>( ex );
+         }
+
+         checkTransposeResults<TVT1,TVT2>();
+      }
+
+
+      //=====================================================================================
+      // Conj subtraction with subtraction assignment
+      //=====================================================================================
+
+      // Conj subtraction with subtraction assignment with the given vectors
+      {
+         test_  = "Conj subtraction with subtraction assignment with the given types";
+         error_ = "Failed subtraction assignment operation";
+
+         try {
+            initResults();
+            dres_   -= conj( lhs_ - rhs_ );
+            sres_   -= conj( lhs_ - rhs_ );
+            refres_ -= conj( reflhs_ - refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<VT1,VT2>( ex );
+         }
+
+         checkResults<VT1,VT2>();
+
+         try {
+            initTransposeResults();
+            tdres_   -= conj( tlhs_ - trhs_ );
+            tsres_   -= conj( tlhs_ - trhs_ );
+            trefres_ -= conj( treflhs_ - trefrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<TVT1,TVT2>( ex );
+         }
+
+         checkTransposeResults<TVT1,TVT2>();
+      }
+
+      // Conj subtraction with subtraction assignment with evaluated vectors
+      {
+         test_  = "Conj subtraction with subtraction assignment with evaluated vectors";
+         error_ = "Failed subtraction assignment operation";
+
+         try {
+            initResults();
+            dres_   -= conj( eval( lhs_ ) - eval( rhs_ ) );
+            sres_   -= conj( eval( lhs_ ) - eval( rhs_ ) );
+            refres_ -= conj( eval( reflhs_ ) - eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<VT1,VT2>( ex );
+         }
+
+         checkResults<VT1,VT2>();
+
+         try {
+            initTransposeResults();
+            tdres_   -= conj( eval( tlhs_ ) - eval( trhs_ ) );
+            tsres_   -= conj( eval( tlhs_ ) - eval( trhs_ ) );
+            trefres_ -= conj( eval( treflhs_ ) - eval( trefrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<TVT1,TVT2>( ex );
+         }
+
+         checkTransposeResults<TVT1,TVT2>();
+      }
+
+
+      //=====================================================================================
+      // Conj subtraction with multiplication assignment
+      //=====================================================================================
+
+      // Conj subtraction with multiplication assignment with the given vectors
+      {
+         test_  = "Conj subtraction with multiplication assignment with the given vectors";
+         error_ = "Failed multiplication assignment operation";
+
+         try {
+            initResults();
+            dres_   *= conj( lhs_ - rhs_ );
+            sres_   *= conj( lhs_ - rhs_ );
+            refres_ *= conj( reflhs_ - refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<VT1,VT2>( ex );
+         }
+
+         checkResults<VT1,VT2>();
+
+         try {
+            initTransposeResults();
+            tdres_   *= conj( tlhs_ - trhs_ );
+            tsres_   *= conj( tlhs_ - trhs_ );
+            trefres_ *= conj( treflhs_ - trefrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<TVT1,TVT2>( ex );
+         }
+
+         checkTransposeResults<TVT1,TVT2>();
+      }
+
+      // Conj subtraction with multiplication assignment with evaluated vectors
+      {
+         test_  = "Conj subtraction with multiplication assignment with evaluated vectors";
+         error_ = "Failed multiplication assignment operation";
+
+         try {
+            initResults();
+            dres_   *= conj( eval( lhs_ ) - eval( rhs_ ) );
+            sres_   *= conj( eval( lhs_ ) - eval( rhs_ ) );
+            refres_ *= conj( eval( reflhs_ ) - eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<VT1,VT2>( ex );
+         }
+
+         checkResults<VT1,VT2>();
+
+         try {
+            initTransposeResults();
+            tdres_   *= conj( eval( tlhs_ ) - eval( trhs_ ) );
+            tsres_   *= conj( eval( tlhs_ ) - eval( trhs_ ) );
+            trefres_ *= conj( eval( treflhs_ ) - eval( trefrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<TVT1,TVT2>( ex );
+         }
+
+         checkTransposeResults<TVT1,TVT2>();
+      }
+   }
+#endif
+}
+//*************************************************************************************************
+
+
+//*************************************************************************************************
 /*!\brief Testing the evaluated dense vector/dense vector subtraction.
 //
 // \return void


Update Msg.h

Update Msg.h

--- src/resource/Arduino/MRLComm/Msg.h
+++ src/resource/Arduino/MRLComm/Msg.h
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
 /**
  *

  *
@@ -32,6 +31,9 @@

 #include <Arduino.h>
 #include "ArduinoMsgCodec.h"
+#if defined(ESP8266)
+  #include "MrlWS.h"
+#endif

 // forward defines to break circular dependency
 class MrlComm;
@@ -52,7 +54,11 @@
 	byte sendBuffer[MAX_MSG_SIZE];

 	// serial references
+#ifndef ESP8266
 	HardwareSerial* serial;
+#else
+  MrlWS* serial;
+#endif

 	// heartbeat
 	bool heartbeat;
@@ -101,7 +107,7 @@
 	void publishI2cData( byte deviceId, const byte* data,  byte dataSize);
 	void publishDebug(const char* debugMsg,  byte debugMsgSize);
 	void publishPinArray(const byte* data,  byte dataSize);
-	void publishServoEvent( byte deviceId,  byte eventType,  int currentPos,  int targetPos);
+	void publishServoEvent( byte deviceId,  byte eventType,  byte currentPos,  byte targetPos);
 	void publishSerialData( byte deviceId, const byte* data,  byte dataSize);
 	void publishUltrasonicSensorData( byte deviceId,  int echoTime);

@@ -110,7 +116,6 @@
 	void processCommand();

 	// io
-	void begin(HardwareSerial& hardwareSerial);
 	void write(const unsigned char value);
 	void writebool(const bool value);
 	void writeb16(const int value);
@@ -120,145 +125,13 @@
 	void write(const unsigned char* buffer, int len);
 	bool readMsg();
 	byte getMethod();
-
+#if defined(ESP8266)
+  void begin(WebSocketsServer& wsServer);
+  void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t lenght);
+#else
+  void begin(HardwareSerial& hardwareSerial);
+#endif
 };

 #endif // Mrl_h
-=======
-/**
- *

- *
-	Welcome to Msg.h
-	Its created by running ArduinoMsgGenerator
-	which combines the MrlComm message schema (src/resource/Arduino/generate/arduinoMsg.schema)
-	with the cpp template (src/resource/Arduino/generate/Msg.template.cpp)
-
-	IDL Type Conversions
-
-	IDL        ARDUINO					Java							Range
-	none		byte/unsigned char		int (cuz Java byte bites)		1 byte - 0 to 255
-	boolean		boolean					boolean							0 1
-    b16			int						int (short)						2 bytes	-32,768 to 32,767
-    b32			long					int								4 bytes -2,147,483,648 to 2,147,483, 647
-    bu32		unsigned long			long							0 to 4,294,967,295
-    str			char*, size				String							variable length
-    []			byte[], size			int[]							variable length
-
-	All message editing should be done in the arduinoMsg.schema
-
-	The binary wire format of an Arduino is:
-
-	MAGIC_NUMBER|MSG_SIZE|METHOD_NUMBER|PARAM0|PARAM1 ...
-
-

-*/
-
-#ifndef Msg_h
-#define Msg_h
-
-#include <Arduino.h>
-#include "ArduinoMsgCodec.h"
-#if defined(ESP8266)
-  #include "MrlWS.h"
-#endif
-
-// forward defines to break circular dependency
-class MrlComm;
-
-class Msg {
-
-public:
-	bool debug = false;
-
-private:
-	// msg reading FIXME - rename recvBuffer
-	byte ioCmd[MAX_MSG_SIZE];
-
-	int byteCount = 0;
-	int msgSize = 0;
-
-	int sendBufferSize = 0;
-	byte sendBuffer[MAX_MSG_SIZE];
-
-	// serial references
-#ifndef ESP8266
-	HardwareSerial* serial;
-#else
-  MrlWS* serial;
-#endif
-
-	// heartbeat
-	bool heartbeat;
-	unsigned long lastHeartbeatUpdate;
-
-	// implements callback
-	MrlComm* mrlComm;
-
-	// my singlton instance
-	static Msg* instance;
-
-    // private constructor
-    Msg();
-
-public:
-    ~Msg();
-    static Msg* getInstance(MrlComm* mrlComm);
-    static Msg* getInstance();
-
-    // send buffering methods
-    void add(const int value);
-    void add16(const int value);
-    void add(unsigned long value);
-    byte* getBuffer();
-    int getBufferSize();
-    void reset();
-    void flush();
-
-    // utility methods
-    static int b16(const unsigned char* buffer, const int start = 0);
-    static long b32(const unsigned char* buffer, const int start = 0);
-    static unsigned long bu32(const unsigned char* buffer, const int start = 0);
-    static float f32(const unsigned char* buffer, const int start = 0);
-
-    // FIXME - remove publishBoardInfo() .. its generated
-    static void publishBoardInfo();
-    void publishError(const String& message);
-    void publishDebug(const String& message);
-
-	// generated send (PC <-- MrlComm) methods
-	void publishMRLCommError(const char* errorMsg,  byte errorMsgSize);
-	void publishBoardInfo( byte version,  byte boardType,  int microsPerLoop,  int sram,  byte activePins, const byte* deviceSummary,  byte deviceSummarySize);
-	void publishAck( byte function);
-	void publishEcho( float myFloat,  byte myByte,  float secondFloat);
-	void publishCustomMsg(const byte* msg,  byte msgSize);
-	void publishI2cData( byte deviceId, const byte* data,  byte dataSize);
-	void publishDebug(const char* debugMsg,  byte debugMsgSize);
-	void publishPinArray(const byte* data,  byte dataSize);
-	void publishServoEvent( byte deviceId,  byte eventType,  byte currentPos,  byte targetPos);
-	void publishSerialData( byte deviceId, const byte* data,  byte dataSize);
-	void publishUltrasonicSensorData( byte deviceId,  int echoTime);
-
-	// handles all (PC --> MrlComm) methods
-	// void handle(int[] ioCmd); // send size too ?
-	void processCommand();
-
-	// io
-	void write(const unsigned char value);
-	void writebool(const bool value);
-	void writeb16(const int value);
-	void writeb32(const long value);
-	void writebu32(const unsigned long value);
-	void writef32(const float value);
-	void write(const unsigned char* buffer, int len);
-	bool readMsg();
-	byte getMethod();
-#if defined(ESP8266)
-  void begin(WebSocketsServer& wsServer);
-  void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t lenght);
-#else
-  void begin(HardwareSerial& hardwareSerial);
-#endif
-};
-
-#endif // Mrl_h
->>>>>>> refs/remotes/origin/develop
+


Fix some unused variable references.

Fix some unused variable references.

git-svn-id: 4705079bc6b8aadf675e3696f5c015a6aa4916e3@4208 3c1deb5b-d424-0410-962d-aba41a686d42

--- source/graphics/mcubes.c
+++ source/graphics/mcubes.c
@@ -787,7 +787,7 @@
 Add mc_triangle to mc_cell list and add new vertex if unique
 ==============================================================================*/
 {
-	int n, nn, jj, kk, i_min, i_max, j_min, j_max, k_min, k_max, found;
+	int n, nn, jj, kk, found;
 	/* pointers to vertices */
 	struct MC_vertex *v[3];
 	struct MC_triangle *triangle,**temp_triangle_ptrs,**temp_triangle_list;
@@ -802,59 +802,10 @@
   USE_PARAMETER(z_max);
   USE_PARAMETER(mcnz);
   USE_PARAMETER(n_scalar_fields);
-	i_min=i_max=i;
-	j_min=j_max=j;
-	k_min=k_max=k;
-	if (i>0)
-	{
-		i_min=i-1;
-	}
-	if (i < mc_iso_surface->dimension[0]+1)
-	{
-		i_max=i+1;
-	}
-	if (j>0)
-	{
-		j_min=j-1;
-	}
-	if (j < mc_iso_surface->dimension[1]+1)
-	{
-		j_max=j+1;
-	}
-	if (k>0)
-	{
-		k_min=k-1;
-	}
-	if (k < mc_iso_surface->dimension[2]+1)
-	{
-		k_max=k+1;
-	}
 	/* step through each vertex */
 	for (n=0;n<3;n++)
 	{
 		found=0;
-#if defined (OLD_CODE)
-		for (kk=k_min;kk<=k_max;kk++)
-		{
-			for (jj=j_min;jj<=j_max;jj++)
-			{
-				for (ii=i_min;ii<=i_max;ii++)
-				{
-					if ((NULL !=mc_iso_surface->mc_cells[ii+mcnx*jj+mcnx*mcny*kk])&&
-						!found)
-					{
-						v[n]=check_mc_vertex(
-							mc_iso_surface->mc_cells[ii+mcnx*jj+mcnx*mcny*kk],mc_vertices[n],
-							a);
-						if (NULL !=v[n])
-						{
-							found=1;
-						}
-					}
-				}
-			}
-		}
-#endif /* defined (OLD_CODE) */
 		USE_PARAMETER(jj);
 		USE_PARAMETER(kk);
 		USE_PARAMETER(check_mc_vertex);


Added missing err_macros.h to tst_nc4perf.c

--- nc_test4/tst_nc4perf.c
+++ nc_test4/tst_nc4perf.c
@@ -1,4 +1,4 @@
-/*
+/*
 Copyright 2009, UCAR/Unidata
 See COPYRIGHT file for copying and redistribution conditions.

@@ -10,6 +10,7 @@
 */

 #include "nc_tests.h"
+#include "err_macros.h"

 #define FILENAME "tst_nc4perf.nc"
 #define NDIMS1 2
@@ -27,9 +28,9 @@

 /* This function creates a file with 10 2D variables, no unlimited
  * dimension. */
-int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm,
-		MPI_Info info, int mpi_size, int mpi_rank,
-		size_t *chunk_size)
+int test_pio_2d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm,
+		MPI_Info info, int mpi_size, int mpi_rank,
+		size_t *chunk_size)
 {
    double starttime, endtime, write_time = 0, bandwidth = 0;
    int ncid;
@@ -37,7 +38,7 @@
    size_t start[NDIMS1], count[NDIMS1];
    float *data;
    char file_name[NC_MAX_NAME + 1];
-   char var_name1[NUMVARS][NC_MAX_NAME + 1] = {"GWa", "JAd", "TJe", "JMa", "JMo",
+   char var_name1[NUMVARS][NC_MAX_NAME + 1] = {"GWa", "JAd", "TJe", "JMa", "JMo",
 					       "JQA", "AJa", "MVB", "WHH", "JTy"};
    int varid1[NUMVARS];
    size_t nelems_in;
@@ -61,7 +62,7 @@
    for (t = 0; t < NUM_TRIES; t++)
    {
       /* Create a netcdf-4 file, opened for parallel I/O. */
-      if (nc_create_par(file_name, facc_type|NC_NETCDF4, comm,
+      if (nc_create_par(file_name, facc_type|NC_NETCDF4, comm,
 			info, &ncid)) ERR;

       /* Create two dimensions. */
@@ -86,7 +87,7 @@
       count[1] = DIMSIZE1 / mpi_size;

       /* start parallel netcdf4 */
-      for (i = 0; i < NUMVARS; i++)
+      for (i = 0; i < NUMVARS; i++)
 	 if (nc_var_par_access(ncid, varid1[i], access_flag)) ERR;

       starttime = MPI_Wtime();
@@ -99,15 +100,15 @@
       if (nc_close(ncid)) ERR;

       endtime = MPI_Wtime();
-      if (!mpi_rank)
+      if (!mpi_rank)
       {
-	 bandwidth += ((sizeof(float) * DIMSIZE1 * DIMSIZE2 * NUMVARS) /
+	 bandwidth += ((sizeof(float) * DIMSIZE1 * DIMSIZE2 * NUMVARS) /
 		       ((endtime - starttime) * 1024 * 1024)) / NUM_TRIES;
 	 write_time += (endtime - starttime) / NUM_TRIES;
       }
    }
    free(data);
-   if (!mpi_rank)
+   if (!mpi_rank)
    {
       char chunk_string[NC_MAX_NAME + 1] = "";

@@ -118,15 +119,15 @@
 	 strcat(chunk_string, "contiguous");

       /* Print the results. */
-      printf("%d\t\t%s\t%s\t%d\t\t%dx%d\t\t%s\t%f\t\t%f\t\t\t%d\n", mpi_size,
-	     (facc_type == NC_MPIIO ? "MPI-IO   " : "MPI-POSIX"),
-	     (access_flag == NC_INDEPENDENT ? "independent" : "collective"),
-	     (int)cache_size/MEGABYTE, DIMSIZE1, DIMSIZE2, chunk_string,
-	     write_time, bandwidth, NUM_TRIES);
+      printf("%d\t\t%s\t%s\t%d\t\t%dx%d\t\t%s\t%f\t\t%f\t\t\t%d\n", mpi_size,
+	     (facc_type == NC_MPIIO ? "MPI-IO   " : "MPI-POSIX"),
+	     (access_flag == NC_INDEPENDENT ? "independent" : "collective"),
+	     (int)cache_size/MEGABYTE, DIMSIZE1, DIMSIZE2, chunk_string,
+	     write_time, bandwidth, NUM_TRIES);
    }

    /* Delete this file. */
-   remove(file_name);
+   remove(file_name);

    return 0;
 }
@@ -134,14 +135,14 @@
 /* Both read and write will be tested */
 /* Case 2: create four dimensional integer data,
    one dimension is unlimited. */
-int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm,
-		MPI_Info info, int mpi_size, int mpi_rank, size_t *chunk_size)
+int test_pio_4d(size_t cache_size, int facc_type, int access_flag, MPI_Comm comm,
+		MPI_Info info, int mpi_size, int mpi_rank, size_t *chunk_size)
 {
    int ncid, dimuids[NDIMS2], varid2[NUMVARS];
    size_t ustart[NDIMS2], ucount[NDIMS2];
    float *udata, *tempudata;
    char file_name[NC_MAX_NAME + 1];
-   char var_name2[NUMVARS][NC_MAX_NAME + 1] = {"JKP", "ZTa", "MFi", "FPi", "JBu",
+   char var_name2[NUMVARS][NC_MAX_NAME + 1] = {"JKP", "ZTa", "MFi", "FPi", "JBu",
 					       "ALi", "AJo", "USG", "RBH", "JAG"};
    double starttime, endtime, write_time = 0, bandwidth = 0;
    size_t nelems_in;
@@ -162,7 +163,7 @@

    /* Get the file name. */
    sprintf(file_name, "%s/%s", TEMP_LARGE, FILENAME);
-
+
    /* Set the cache size. */
    if (nc_get_chunk_cache(NULL, &nelems_in, &preemption_in)) ERR;
    if (nc_set_chunk_cache(cache_size, nelems_in, preemption_in)) ERR;
@@ -170,7 +171,7 @@
    for (t = 0; t < NUM_TRIES; t++)
    {
       /* Create a netcdf-4 file. */
-      if (nc_create_par(file_name, facc_type|NC_NETCDF4, comm, info,
+      if (nc_create_par(file_name, facc_type|NC_NETCDF4, comm, info,
 			&ncid)) ERR;

       /* Create four dimensions. */
@@ -185,7 +186,7 @@
 			dimuids, &varid2[i])) ERR;

       if (nc_enddef(ncid)) ERR;
-
+
       /* Set up selection parameters */
       ustart[0] = 0;
       ustart[1] = 0;
@@ -214,7 +215,7 @@
       if (!mpi_rank)
       {
 	 write_time += (endtime - starttime) / NUM_TRIES;
-	 bandwidth += (sizeof(float) * TIMELEN * DIMSIZE1 * DIMSIZE2 * DIMSIZE3 * NUMVARS) /
+	 bandwidth += (sizeof(float) * TIMELEN * DIMSIZE1 * DIMSIZE2 * DIMSIZE3 * NUMVARS) /
 	    ((endtime - starttime) * 1024 * 1024 * NUM_TRIES);
       }
    }
@@ -225,21 +226,21 @@

       /* What was our chunking? */
       if (chunk_size[0])
-	 sprintf(chunk_string, "%dx%dx%dx%d", (int)chunk_size[0], (int)chunk_size[1],
+	 sprintf(chunk_string, "%dx%dx%dx%d", (int)chunk_size[0], (int)chunk_size[1],
 		 (int)chunk_size[2], (int)chunk_size[3]);
       else
 	 strcat(chunk_string, "contiguous");

       /* Print our results. */
-      printf("%d\t\t%s\t%s\t%d\t\t%dx%dx%dx%d\t%s\t%f\t\t%f\t\t\t%d\n", mpi_size,
-	     (facc_type == NC_MPIIO ? "MPI-IO   " : "MPI-POSIX"),
-	     (access_flag == NC_INDEPENDENT ? "independent" : "collective"),
-	     (int)cache_size / MEGABYTE, TIMELEN, DIMSIZE3, DIMSIZE2, DIMSIZE1, chunk_string, write_time,
-	     bandwidth, NUM_TRIES);
+      printf("%d\t\t%s\t%s\t%d\t\t%dx%dx%dx%d\t%s\t%f\t\t%f\t\t\t%d\n", mpi_size,
+	     (facc_type == NC_MPIIO ? "MPI-IO   " : "MPI-POSIX"),
+	     (access_flag == NC_INDEPENDENT ? "independent" : "collective"),
+	     (int)cache_size / MEGABYTE, TIMELEN, DIMSIZE3, DIMSIZE2, DIMSIZE1, chunk_string, write_time,
+	     bandwidth, NUM_TRIES);
    }

    /* Delete this file. */
-   remove(file_name);
+   remove(file_name);

    return 0;
 }
@@ -262,11 +263,11 @@
    int mpi_size, mpi_rank;
    int mpi_mode[NUM_MODES] = {NC_MPIIO, NC_MPIPOSIX};
    int facc_type[NUM_FACC] = {NC_INDEPENDENT, NC_COLLECTIVE};
-   size_t chunk_size_2d[NUM_CHUNK_COMBOS_2D][NDIMS1] = {{0, 0},
+   size_t chunk_size_2d[NUM_CHUNK_COMBOS_2D][NDIMS1] = {{0, 0},
 							{DIMSIZE2, DIMSIZE1},
 							{DIMSIZE2/2 + 1, DIMSIZE1 / 2}};
-   size_t chunk_size_4d[NUM_CHUNK_COMBOS_4D][NDIMS2] = {{0, 0, 0, 0},
-							{1, DIMSIZE3, DIMSIZE2, DIMSIZE1},
+   size_t chunk_size_4d[NUM_CHUNK_COMBOS_4D][NDIMS2] = {{0, 0, 0, 0},
+							{1, DIMSIZE3, DIMSIZE2, DIMSIZE1},
 							{TIMELEN / 2, DIMSIZE3 / 2 + 1, DIMSIZE2 / 2 + 1, DIMSIZE1 / 2},
 							{TIMELEN, DIMSIZE3, DIMSIZE2, DIMSIZE1}};
    size_t cache_size[NUM_CACHE_SIZES] = {MEGABYTE, 32 * MEGABYTE, 64 * MEGABYTE};
@@ -280,7 +281,7 @@
    /* Check for invalid number of processors. */
    if ((float)DIMSIZE1 / mpi_size != (int)(DIMSIZE1 / mpi_size))
    {
-      printf("%d divided by number of processors must be a whole number!\n",
+      printf("%d divided by number of processors must be a whole number!\n",
 	     DIMSIZE1);
       return -1;
    }
@@ -296,17 +297,17 @@
       for (m = 0; m < NUM_MODES; m++)
 	 for (f = 0; f < NUM_FACC; f++)
 	    for (c = 0; c < NUM_CHUNK_COMBOS_2D; c++)
-	       if (test_pio_2d(cache_size[i], mpi_mode[m], facc_type[f], comm,
+	       if (test_pio_2d(cache_size[i], mpi_mode[m], facc_type[f], comm,
 			       info, mpi_size, mpi_rank, chunk_size_2d[c])) ERR;

    for (i = 0; i < NUM_CACHE_SIZES; i++)
       for (m = 0; m < NUM_MODES; m++)
 	 for (f = 0; f < NUM_FACC; f++)
 	    for (c = 0; c < NUM_CHUNK_COMBOS_4D; c++)
-	       if (test_pio_4d(cache_size[i], mpi_mode[m], facc_type[f], comm,
-			       info, mpi_size, mpi_rank, chunk_size_4d[c])) ERR;
-
-   if (!mpi_rank)
+	       if (test_pio_4d(cache_size[i], mpi_mode[m], facc_type[f], comm,
+			       info, mpi_size, mpi_rank, chunk_size_4d[c])) ERR;
+
+   if (!mpi_rank)
       SUMMARIZE_ERR;
    MPI_Finalize();

@@ -315,4 +316,3 @@

    return 0;
 }
-


fixing wow64 without crt

fixing wow64 without crt

--- source/push[exe]/wow64.c
+++ source/push[exe]/wow64.c
@@ -134,17 +134,27 @@
     }
 }

+
+VOID* Module_GetProcedureAddress(VOID* DllHandle, CHAR* ProcedureName);
+VOID* Module_Load(WCHAR* FileName);
+INT32 String_Compare(WCHAR* Source, WCHAR* dst);
+VOID Memory_Clear(VOID* Region, UINT32 Size);
+
+
 unsigned long long GetModuleHandle64(wchar_t* ModuleName)
 {
     unsigned long long Current = 0;
     unsigned long long ulModule = 0;

-
-    wchar_t szBuffer[512] = { 0 };
-
-    PEB64 Peb64 = { 0 };
-    LDR64 Ldr64 = { 0 };
-    LDR_DATA_TABLE_ENTRY64 LdrEntry64 = { 0 };
+	wchar_t szBuffer[512];
+	PEB64 Peb64;
+	LDR64 Ldr64;
+	LDR_DATA_TABLE_ENTRY64 LdrEntry64;
+
+	Memory_Clear(szBuffer, sizeof(szBuffer));
+	Memory_Clear(&Peb64, sizeof(PEB64));
+	Memory_Clear(&Ldr64, sizeof(LDR64));
+	Memory_Clear(&LdrEntry64, sizeof(LDR_DATA_TABLE_ENTRY64));

     GetPEB64(&Peb64);

@@ -324,16 +334,23 @@

     unsigned long long ulFunction = 0;

-    IMAGE_DOS_HEADER DosHeader = { 0 };
-    IMAGE_NT_HEADERS64 NtHeaders = { 0 };
+	IMAGE_DOS_HEADER DosHeader;
+	IMAGE_NT_HEADERS64 NtHeaders;
+
+	Memory_Clear(&DosHeader, sizeof(IMAGE_DOS_HEADER));
+	Memory_Clear(&NtHeaders, sizeof(IMAGE_NT_HEADERS64));

     memcpy64((unsigned long long)&DosHeader, ulModule, sizeof(IMAGE_DOS_HEADER));
     memcpy64((unsigned long long)&NtHeaders, ulModule + DosHeader.e_lfanew, sizeof(IMAGE_NT_HEADERS64));

     if (NtHeaders.Signature == IMAGE_NT_SIGNATURE)
     {
-        char szName[256] = { 0 };
-        IMAGE_EXPORT_DIRECTORY Exports = { 0 };
+		char szName[256];
+		IMAGE_EXPORT_DIRECTORY Exports;
+
+		Memory_Clear(szName, sizeof(szName));
+		Memory_Clear(&Exports, sizeof(IMAGE_EXPORT_DIRECTORY));
+
         unsigned long ulVA = NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
         unsigned long ulSize = NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
         unsigned long i = 0;
@@ -344,7 +361,8 @@
             memcpy64((unsigned long long)&ulNameOffset, Exports.AddressOfNames + ulModule + (i * 4), sizeof(unsigned long));
             ulNameOffset += ulModule;
             memcpy64((unsigned long long)szName, ulNameOffset, strlen64(ulNameOffset));
-            if (!m_memcmp(szFunction, szName, strlen(szFunction)))
+
+			if (!m_memcmp(szFunction, szName, strlen(szFunction)))
             {
                 unsigned long long ulAddressOffset = 0;
                 unsigned long long ulOrdinalOffset = 0;
@@ -364,6 +382,8 @@

     return ulFunction;
 }
+
+
 #pragma warning( push )
 #pragma warning( disable : 4409)
 #pragma warning( disable : 4102)
@@ -625,19 +645,22 @@
     DWORD64 CsrServerReadOnlySharedMemoryBase;
 }PEB_64;

-VOID* Module_GetProcedureAddress(VOID* DllHandle, CHAR* ProcedureName);
-VOID* Module_Load(WCHAR* FileName);
+
 typedef enum _PROCESSINFOCLASS
 {
     ProcessBasicInformation, // 0, q: PROCESS_BASIC_INFORMATION, PROCESS_EXTENDED_BASIC_INFORMATION
     ProcessQuotaLimits
 }PROCESSINFOCLASS;
 #define STATUS_SUCCESS                  ((NTSTATUS)0x00000000L)
+
+
 VOID* GetRemoteProcessEnvironmentBlock(HANDLE ProcessHandle, PEB_64* ProcessEnvironmentBlock)
 {
-    PROCESS_BASIC_INFORMATION_64 info = { 0 };
+	PROCESS_BASIC_INFORMATION_64 info;
     ULONG bytes = 0;
     NTSTATUS status;
+
+	Memory_Clear(&info, sizeof(PROCESS_BASIC_INFORMATION_64));

     NtWow64QueryInformationProcess64 = (TYPE_NtWow64QueryInformationProcess64)Module_GetProcedureAddress(
         Module_Load(L"ntdll.dll"),
@@ -712,11 +735,14 @@
     DWORD64 PatchInformation;
 }LDR_DATA_TABLE_ENTRY_BASE_64;

-INT32 String_Compare(WCHAR* Source, WCHAR* dst);
+
 DWORD64 GetRemoteModuleHandle(HANDLE ProcessHandle, WCHAR* ModuleName)
 {
-    PEB_64 peb = { 0 };
-    PEB_LDR_DATA_64 ldr = { 0 };
+	PEB_64 peb;
+	PEB_LDR_DATA_64 ldr;
+
+	Memory_Clear(&peb, sizeof(PEB_64));
+	Memory_Clear(&ldr, sizeof(PEB_LDR_DATA_64));

     GetRemoteProcessEnvironmentBlock(ProcessHandle, &peb);

@@ -776,8 +802,8 @@

 DWORD64 GetRemoteProcAddress(HANDLE ProcessHandle, DWORD64 BaseAddress, const char* name_ord)
 {
-	IMAGE_DOS_HEADER hdrDos = { 0 };
-	UINT8 hdrNt32[sizeof(IMAGE_NT_HEADERS64)] = { 0 };
+	IMAGE_DOS_HEADER hdrDos;
+	UINT8 hdrNt32[sizeof(IMAGE_NT_HEADERS64)];
 	PIMAGE_NT_HEADERS32 phdrNt32 = (PIMAGE_NT_HEADERS32)(hdrNt32);
     PIMAGE_NT_HEADERS64 phdrNt64 = (PIMAGE_NT_HEADERS64)(hdrNt32);
 	IMAGE_EXPORT_DIRECTORY* pExpData;
@@ -787,6 +813,9 @@
 	DWORD *pAddressOfNames;
 	DWORD *pAddressOfFuncs;
 	DWORD i;
+
+	Memory_Clear(&hdrDos, sizeof(IMAGE_DOS_HEADER));
+	Memory_Clear(&hdrNt32, sizeof(hdrNt32));

     /// Invalid module
     if (BaseAddress == 0)


net: switchdev: ignore unsupported bridge flags

switchdev_port_bridge_getlink() queries SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS
attributes, but a driver doesn't need to implement this in order to get
bridge link information.

So error out only on errors different than -EOPNOTSUPP.

(This is a follow-up patch for 7d4f8d8.)

Fixes: 8793d0a664a8 ("switchdev: add new switchdev_port_bridge_getlink")
Signed-off-by: Vivien Didelot <8fdc57bfa92d8dfa7873c6f9e93ed744bd3ae60c@savoirfairelinux.com>
Acked-by: Jiri Pirko <1b548d10035ae428195c41f5d55eedb1437ccd8a@resnulli.us>
Acked-by: Scott Feldman <63753295bdfa1c38e2e58f32ad4349adf9b4ba29@gmail.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


econet: Use sock_orphan() instead of open-coded (and buggy) variant.

It doesn't grab the sk_callback_lock, it doesn't NULL out
the sk->sk_sleep waitqueue pointer, etc.

Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/econet/af_econet.c
+++ net/econet/af_econet.c
@@ -573,9 +573,7 @@

 	sk->sk_state_change(sk);	/* It is useless. Just for sanity. */

-	sock->sk = NULL;
-	sk->sk_socket = NULL;
-	sock_set_flag(sk, SOCK_DEAD);
+	sock_orphan(sk);

 	/* Purge queues */


Don't attempt to optimize the space allocated for bpf headers if sizeof(struct bpf_hdr) > 20.  20 is normal on 32-bit systems with 32-bit alignment, but we still assume that the last 2 bytes of the struct are unnecessary padding on such systems.  On systems with 64-bit longs, struct timeval is bloated to 16 bytes, so bpf headers certainly don't fit in 18 bytes.

--- sys/net/bpf.h
+++ sys/net/bpf.h
@@ -38,7 +38,7 @@
  *      @(#)bpf.h	8.1 (Berkeley) 6/10/93
  *	@(#)bpf.h	1.34 (LBL)     6/16/96
  *
- * $Id$
+ * $Id: bpf.h,v 1.12 1997/02/22 09:40:55 peter Exp $
  */

 #ifndef _NET_BPF_H_
@@ -128,7 +128,8 @@
  * Only the kernel needs to know about it; applications use bh_hdrlen.
  */
 #ifdef KERNEL
-#define SIZEOF_BPF_HDR 18
+#define	SIZEOF_BPF_HDR	(sizeof(struct bpf_hdr) <= 20 ? 18 : \
+    sizeof(struct bpf_hdr))
 #endif

 /*


For the sake of people, who like to move pci_configure()
before isa_configure() in autoconf.c:

ncr_intr() protected by splbio()/splx()

Submitted by:	wolf


- better inline docs, part #4

- better inline docs, part #4

--- http_requestpool_object.c
+++ http_requestpool_object.c
@@ -144,7 +144,15 @@
  *
  * Instantiate a new HttpRequestPool object.  An HttpRequestPool is
  * able to send several HttpRequests in parallel.
- *
+ *
+ * WARNING: Don't attach/detach HttpRequest objects to the HttpRequestPool
+ * object while you're using the implemented Interator interface.
+ *
+ * Accepts virtual infinite optional parameters each referencing an
+ * HttpRequest object.
+ *
+ * Throws HttpRequestException, HttpRequestPoolException, HttpInvalidParamException.
+ *
  * Example:
  *

  * <?php
@@ -216,7 +224,15 @@
 /* {{{ proto bool HttpRequestPool::attach(HttpRequest request)
  *
  * Attach an HttpRequest object to this HttpRequestPool.
- * NOTE: set all options prior attaching!
+ * WARNING: set all options prior attaching!
+ *
+ * Expects the parameter to be an HttpRequest object not alread attached to
+ * antother HttpRequestPool object.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ *
+ * Throws HttpInvalidParamException, HttpRequestException,
+ * HttpRequestPoolException, HttpEncodingException.
  */
 PHP_METHOD(HttpRequestPool, attach)
 {
@@ -236,6 +252,13 @@
 /* {{{ proto bool HttpRequestPool::detach(HttpRequest request)
  *
  * Detach an HttpRequest object from this HttpRequestPool.
+ *
+ * Expects the parameter to be an HttpRequest object attached to this
+ * HttpRequestPool object.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ *
+ * Throws HttpInvalidParamException, HttpRequestPoolException.
  */
 PHP_METHOD(HttpRequestPool, detach)
 {
@@ -255,6 +278,11 @@
 /* {{{ proto bool HttpRequestPool::send()
  *
  * Send all attached HttpRequest objects in parallel.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ *
+ * Throws HttpSocketException, HttpRequestException,
+ * HttpRequestPoolException, HttpMalformedHeaderException.
  */
 PHP_METHOD(HttpRequestPool, send)
 {
@@ -271,8 +299,10 @@
 }
 /* }}} */

-/* {{{ proto protected bool HttpRequestPool::socketSend()
- *
+/* {{{ proto protected bool HttpRequestPool::socketPerform()
+ *
+ * Returns TRUE until each request has finished its transaction.
+ *
  * Usage:
  *

  * <?php
@@ -303,6 +333,8 @@
 /* {{{ proto protected bool HttpRequestPool::socketSelect()
  *
  * See HttpRequestPool::socketPerform().
+ *
+ * Returns TRUE on success, or FALSE on failure.
  */
 PHP_METHOD(HttpRequestPool, socketSelect)
 {
@@ -358,7 +390,7 @@
 }
 /* }}} */

-/* {{{ proto long HttpRequestPool::key()
+/* {{{ proto int HttpRequestPool::key()
  *
  * Implements Iterator::key().
  */


define OSL_FAIL as replacement for DBG_ERROR

--- sal/inc/osl/diagnose.h
+++ sal/inc/osl/diagnose.h
@@ -91,6 +91,7 @@
 #define OSL_TRACE           _OSL_TRACE
 #define OSL_ASSERT(c)       _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, 0)
 #define OSL_ENSURE(c, m)   _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, m)
+#define OSL_FAIL(m)        _OSL_ENSURE(0, OSL_THIS_FILE, __LINE__, m)

 #define OSL_VERIFY(c) do { if (!(c)) OSL_ASSERT(0); } while (0)
 #define OSL_PRECOND(c, m)   OSL_ENSURE(c, m)


Fixes for Ruby 1.9.1.  Thanks to Michael Fellinger <m.fellinger@gmail.com> for the patch\!

--- src/ruby-binding/rblocalmemcache.c
+++ src/ruby-binding/rblocalmemcache.c
@@ -15,6 +15,15 @@
 #define RSTRING_PTR(x) RSTRING(x)->ptr
 #endif

+#ifndef RARRAY_PTR
+#define RARRAY_PTR(array) array->ptr
+#endif
+
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(array) array->len
+#endif
+
+
 #if RUBY_VERSION_CODE >= 190
 #define ruby_errinfo rb_errinfo()
 #endif
@@ -31,6 +40,7 @@
   return r ? r : "nil";
 }

+/* :nodoc: */
 char *rstring_ptr_null(VALUE s) {
   char* r = NIL_P(s) ? NULL : RSTRING_PTR(rb_String(s));
   return r ? r : NULL;
@@ -94,6 +104,7 @@
   local_memcache_free(rb_lmc_check_handle_access(h), &e);
 }

+/* :nodoc: */
 void lmc_check_dict(VALUE o) {
   if (TYPE(o) != T_HASH) {
     rb_raise(rb_eArgError, "expected a Hash");
@@ -361,8 +372,8 @@
     success = local_memcache_iterate(get_LocalMemCache(obj),
         (void *) &data, &ofs, lmc_ruby_iter_collect_pairs);
     long i;
-    for (i = 0; i < RARRAY(r)->len; i++) {
-      rb_yield(RARRAY(r)->ptr[i]);
+    for (i = 0; i < RARRAY_LEN(r); i++) {
+      rb_yield(RARRAY_PTR(r)[i]);
     }
   }
   if (!success) { return Qnil; }


INTEGRATION: CWS changefileheader (1.5.378); FILE MERGED 2008/04/01 15:25:01 thb 1.5.378.2: #i85898# Stripping all external header guards 2008/03/31 13:23:36 rt 1.5.378.1: #i87441# Change license header to LPGL v3.

--- sal/inc/osl/security.h
+++ sal/inc/osl/security.h
@@ -1,44 +1,37 @@
 /*************************************************************************
  *
- *  OpenOffice.org - a multi-platform office productivity suite
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *  $RCSfile: security.h,v $
+ * Copyright 2008 by Sun Microsystems, Inc.
  *
- *  $Revision: 1.5 $
+ * OpenOffice.org - a multi-platform office productivity suite
  *
- *  last change: $Author: rt $ $Date: 2005-09-08 14:31:32 $
+ * $RCSfile: security.h,v $
+ * $Revision: 1.6 $
  *
- *  The Contents of this file are made available subject to
- *  the terms of GNU Lesser General Public License Version 2.1.
+ * This file is part of OpenOffice.org.
  *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
  *
- *    GNU Lesser General Public License Version 2.1
- *    =============================================
- *    Copyright 2005 by Sun Microsystems, Inc.
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
  *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License version 2.1, as published by the Free Software Foundation.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU Lesser General Public
- *    License along with this library; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *    MA  02111-1307  USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
  *
  ************************************************************************/

 #ifndef _OSL_SECURITY_H_
 #define _OSL_SECURITY_H_

-#ifndef _RTL_USTRING_H_
-#   include <rtl/ustring.h>
-#endif
+#include <rtl/ustring.h>

 #ifdef __cplusplus
 extern "C" {


destroy byte buffer reader after use in ruby recv msg

--- src/ruby/ext/grpc/rb_byte_buffer.c
+++ src/ruby/ext/grpc/rb_byte_buffer.c
@@ -65,5 +65,6 @@
                GPR_SLICE_LENGTH(next));
     gpr_slice_unref(next);
   }
+  grpc_byte_buffer_reader_destroy(&reader);
   return rb_string;
 }


INTEGRATION: CWS changefileheader (1.10.268); FILE MERGED 2008/04/01 12:34:02 thb 1.10.268.2: #i85898# Stripping all external header guards 2008/03/31 13:23:36 rt 1.10.268.1: #i87441# Change license header to LPGL v3.

--- sal/inc/osl/semaphor.h
+++ sal/inc/osl/semaphor.h
@@ -1,44 +1,37 @@
 /*************************************************************************
  *
- *  OpenOffice.org - a multi-platform office productivity suite
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *  $RCSfile: semaphor.h,v $
+ * Copyright 2008 by Sun Microsystems, Inc.
  *
- *  $Revision: 1.10 $
+ * OpenOffice.org - a multi-platform office productivity suite
  *
- *  last change: $Author: hr $ $Date: 2006-06-20 04:13:05 $
+ * $RCSfile: semaphor.h,v $
+ * $Revision: 1.11 $
  *
- *  The Contents of this file are made available subject to
- *  the terms of GNU Lesser General Public License Version 2.1.
+ * This file is part of OpenOffice.org.
  *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
  *
- *    GNU Lesser General Public License Version 2.1
- *    =============================================
- *    Copyright 2005 by Sun Microsystems, Inc.
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
  *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License version 2.1, as published by the Free Software Foundation.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU Lesser General Public
- *    License along with this library; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *    MA  02111-1307  USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
  *
  ************************************************************************/

 #ifndef _OSL_SEMAPHORE_H_
 #define _OSL_SEMAPHORE_H_

-#ifndef _SAL_TYPES_H_
 #include <sal/types.h>
-#endif

 #ifdef __cplusplus
 extern "C" {


INTEGRATION: CWS ooo19126 (1.14.26); FILE MERGED 2005/09/05 17:44:29 rt 1.14.26.1: #i54170# Change license header: remove SISSL

--- sal/osl/unx/security.c
+++ sal/osl/unx/security.c
@@ -1,61 +1,35 @@
 /*************************************************************************
  *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
  *  $RCSfile: security.c,v $
  *
- *  $Revision: 1.14 $
- *
- *  last change: $Author: obo $ $Date: 2005-06-17 09:32:08 $
- *
- *  The Contents of this file are made available subject to the terms of
- *  either of the following licenses
- *
- *         - GNU Lesser General Public License Version 2.1
- *         - Sun Industry Standards Source License Version 1.1
- *
- *  Sun Microsystems Inc., October, 2000
- *
- *  GNU Lesser General Public License Version 2.1
- *  =============================================
- *  Copyright 2000 by Sun Microsystems, Inc.
- *  901 San Antonio Road, Palo Alto, CA 94303, USA
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License version 2.1, as published by the Free Software Foundation.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *  MA  02111-1307  USA
- *
- *
- *  Sun Industry Standards Source License Version 1.1
- *  =================================================
- *  The contents of this file are subject to the Sun Industry Standards
- *  Source License Version 1.1 (the "License"); You may not use this file
- *  except in compliance with the License. You may obtain a copy of the
- *  License at http://www.openoffice.org/license.html.
- *
- *  Software provided under this License is provided on an "AS IS" basis,
- *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- *  See the License for the specific provisions governing your rights and
- *  obligations concerning the Software.
- *
- *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- *  Copyright: 2000 by Sun Microsystems, Inc.
- *
- *  All Rights Reserved.
- *
- *  Contributor(s): _______________________________________
- *
+ *  $Revision: 1.15 $
+ *
+ *  last change: $Author: rt $ $Date: 2005-09-08 15:00:23 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License version 2.1, as published by the Free Software Foundation.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Lesser General Public License for more details.
+ *
+ *    You should have received a copy of the GNU Lesser General Public
+ *    License along with this library; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA
  *
  ************************************************************************/


Use an anonymous function to execute user scripts

--- midori/midori-addons.c
+++ midori/midori-addons.c
@@ -176,7 +176,7 @@
     {
         /* Wrap the script to prevent global variables */
         gchar* wrapped_script = g_strdup_printf (
-            "var wrapped = function () { %s }; wrapped ();", script);
+            "(function () { %s })();", script);
         if (gjs_script_eval (js_context, wrapped_script, exception))
             result = TRUE;
         g_free (wrapped_script);


ipv6: fix a potential use after free in ip6_offload.c

pskb_may_pull() maybe change skb->data and make opth pointer oboslete,
so set the opth again

Signed-off-by: Li RongQing <81c2f95e9d1350da984a3ef03e964ca9a6cbc5c2@gmail.com>
Acked-by: Eric Dumazet <312c7d941f03386814be517ffdb3e0eb6624e275@google.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/ipv6/ip6_offload.c
+++ net/ipv6/ip6_offload.c
@@ -46,6 +46,7 @@
 		if (unlikely(!pskb_may_pull(skb, len)))
 			break;

+		opth = (void *)skb->data;
 		proto = opth->nexthdr;
 		__skb_pull(skb, len);
 	}


packet: Use PAGE_ALIGNED macro

packet: Use PAGE_ALIGNED macro

Use PAGE_ALIGNED(...) instead of open-coding it.

Signed-off-by: Tobias Klauser <9249c549618448e4c699e8032ba6c7f0d7fd4b7f@distanz.ch>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/packet/af_packet.c
+++ net/packet/af_packet.c
@@ -4109,7 +4109,7 @@
 		err = -EINVAL;
 		if (unlikely((int)req->tp_block_size <= 0))
 			goto out;
-		if (unlikely(req->tp_block_size & (PAGE_SIZE - 1)))
+		if (unlikely(!PAGE_ALIGNED(req->tp_block_size)))
 			goto out;
 		if (po->tp_version >= TPACKET_V3 &&
 		    (int)(req->tp_block_size -


packet: remove handling of tx_ring from prb_shutdown_retire_blk_timer()

Follow e8e85cc5eb57 ("packet: remove handling of tx_ring") and remove
the tx_ring parameter from prb_shutdown_retire_blk_timer() as it is only
called with tx_ring = 0.

Signed-off-by: Tobias Klauser <9249c549618448e4c699e8032ba6c7f0d7fd4b7f@distanz.ch>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/packet/af_packet.c
+++ net/packet/af_packet.c
@@ -518,13 +518,11 @@
 }

 static void prb_shutdown_retire_blk_timer(struct packet_sock *po,
-		int tx_ring,
 		struct sk_buff_head *rb_queue)
 {
 	struct tpacket_kbdq_core *pkc;

-	pkc = tx_ring ? GET_PBDQC_FROM_RB(&po->tx_ring) :
-			GET_PBDQC_FROM_RB(&po->rx_ring);
+	pkc = GET_PBDQC_FROM_RB(&po->rx_ring);

 	spin_lock_bh(&rb_queue->lock);
 	pkc->delete_blk_timer = 1;
@@ -4044,7 +4042,7 @@
 	if (closing && (po->tp_version > TPACKET_V2)) {
 		/* Because we don't support block-based V3 on tx-ring */
 		if (!tx_ring)
-			prb_shutdown_retire_blk_timer(po, tx_ring, rb_queue);
+			prb_shutdown_retire_blk_timer(po, rb_queue);
 	}
 	release_sock(sk);


peek at input sample

peek at input sample

--- lyd/lyd-ops.c
+++ lyd/lyd-ops.c
@@ -140,17 +140,29 @@
   OP_LOOP(OUT = noise();)
 }

-static inline float input_sample (LydVM *vm,
-                                  int    no)
+static inline float input_sample_peek (LydVM *vm,
+                                       int    no)
 {
   float ret = 0.0;
   if (!vm->input_buf)
     return 0.0;
   if (vm->input_pos[no] < vm->input_buf_len)
     ret = vm->input_buf[no][vm->input_pos[no]];
+  return ret;
+}
+
+static inline float input_sample (LydVM *vm,
+                                  int    no)
+{
+  float ret = 0.0;
+  if (!vm->input_buf)
+    return 0.0;
+  ret = input_sample_peek (vm, no);
   vm->input_pos[no] ++; /* this should not happen here, this
                            makes multiple concurrent uses of the
-                           same input impossible */
+                           same input impossible,
+                           all positions should be iterated together.
+                         */
   return ret;
 }


Exercise 06 Done

Exercise 06 Done

error: pathspec 'ex02/ft_atoi.c' did not match any file(s) known to git


simple

simple

git-svn-id: ae92b08b608af1c8cefa3e10d2325ea527204e07@18687 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- slashd/mds.c
+++ slashd/mds.c
@@ -1675,14 +1675,10 @@
 	BMAP_LOCK(b);
 	obml = mds_bmap_getbml(b, sbd_in);
 	if (!obml) {
-		rc = -ENOENT;
-		BMAP_ULOCK(b);
-		goto out2;
+		PFL_GOTOERR(out2, rc = -ENOENT);

 	} else if (!(obml->bml_flags & BML_WRITE)) {
-		rc = -EINVAL;
-		BMAP_ULOCK(b);
-		goto out2;
+		PFL_GOTOERR(out2, rc = -EINVAL);
 	}

 	bcm_wait_locked(b, b->bcm_flags & BMAP_IONASSIGN);
@@ -1697,9 +1693,7 @@
 		/* Other clients have been assigned this sliod.  Therefore
 		 *   the sliod may not be reassigned.
 		 */
-		rc = -EAGAIN;
-		BMAP_ULOCK(b);
-		goto out1;
+		PFL_GOTOERR(out1, rc = -EAGAIN);
 	}
 	psc_assert(bmi->bmdsi_wr_ion);
 	psc_assert(!(b->bcm_flags & BMAP_DIO));
@@ -1714,10 +1708,8 @@
 	psc_assert(bia.bia_seq == bmi->bmdsi_seq);

 	resm = mds_resm_select(b, pios, prev_ios, nprev_ios);
-	if (!resm) {
-		rc = -SLERR_ION_OFFLINE;
-		goto out1;
-	}
+	if (!resm)
+		PFL_GOTOERR(out1, rc = -SLERR_ION_OFFLINE);

 	/* Deal with the lease renewal and repl_add before modifying
 	 *    the ios part of the lease or bmi so that mds_bmap_add_repl()
@@ -1750,17 +1742,17 @@
 	sbd_out->sbd_key = obml->bml_bmdsi->bmdsi_assign->odtr_key;
 	sbd_out->sbd_ios = obml->bml_ios;
  out1:
-	BMAP_LOCK(b);
+	BMAP_RLOCK(b);
 	psc_assert(b->bcm_flags & BMAP_IONASSIGN);
 	BMAP_CLEARATTR(b, BMAP_IONASSIGN);
 	bcm_wake_locked(b);
-	BMAP_ULOCK(b);
  out2:
-	DEBUG_BMAP(rc ? PLL_WARN : PLL_INFO, b, "rc=%d renew oseq=%"
-	   PRIu64" nseq=%"PRIu64" nid=%"PRIu64" pid=%u",
-	   rc, sbd_in->sbd_seq, (obml ? obml->bml_seq : 0),
-	   exp->exp_connection->c_peer.nid,
-	   exp->exp_connection->c_peer.pid);
+	DEBUG_BMAP(rc ? PLL_WARN : PLL_INFO, b,
+	    "rc=%d renew oseq=%"PRIu64" nseq=%"PRIu64" "
+	    "nid=%"PRIu64" pid=%u",
+	    rc, sbd_in->sbd_seq, (obml ? obml->bml_seq : 0),
+	    exp->exp_connection->c_peer.nid,
+	    exp->exp_connection->c_peer.pid);
 	bmap_op_done_type(b, BMAP_OPCNT_LOOKUP);
 	return (rc);
 }