e_dbus/connman: downgrade log message to DBG
Some dict entries may not be available depending on the dictionary so
don't warn about it.

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

--- src/lib/connman/e_connman_element.c
+++ src/lib/connman/e_connman_element.c
@@ -1851,7 +1851,7 @@
         }
    }

-   WRN("element %s (%p) has no property with name \"%s\".",
+   DBG("element %s (%p) has no property with name \"%s\".",
        element->path, element, dict_name);
    return EINA_FALSE;
 }


we are now using qt 5.7

we are now using qt 5.7

--- quiverlauncher.h
+++ quiverlauncher.h
@@ -33,7 +33,7 @@
         void update_qrc(const Project *project);
         QStringList get_files_in_dir_recursive(const QString &dirpath);
         QString builddirpath;
-        QString qt_version = "5.6";
+        QString qt_version = "5.7";

         void launch_next_process();
         QProcess *process = nullptr;


pedantics -> argb8888 colorspace

pedantics -> argb8888 colorspace

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

--- src/lib/notification/notification.c
+++ src/lib/notification/notification.c
@@ -382,7 +382,8 @@

    EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
-
+
+   evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_ARGB8888);
    evas_object_image_alpha_set(obj, img->has_alpha);
    evas_object_image_size_set(obj, img->width, img->height);


Fix __digestof phi expression returns the wrong type (#2683) (#2691)

--- src/libponyc/codegen/genreference.c
+++ src/libponyc/codegen/genreference.c
@@ -374,7 +374,7 @@
     LLVMBuildBr(c->builder, post_block);

     LLVMPositionBuilderAtEnd(c->builder, post_block);
-    LLVMValueRef phi = LLVMBuildPhi(c->builder, c->i64, "");
+    LLVMValueRef phi = LLVMBuildPhi(c->builder, c->intptr, "");
     LLVMAddIncoming(phi, &box_digest, &box_block, 1);
     LLVMAddIncoming(phi, &nonbox_digest, &nonbox_block, 1);
     return phi;


Fix int32-overflow error in shape computation.

I got the following error message before tracking down this bug:
InvalidArgumentError: Input to reshape is a tensor with 2764800000 values, but the requested shape requires a multiple of 2764800
Change: 114562418

--- tensorflow/core/kernels/reshape_op.h
+++ tensorflow/core/kernels/reshape_op.h
@@ -43,7 +43,7 @@
     // Compute the output shape.  Determine product of specified
     // dimensions, and find the index of the unspecified one.
     TensorShape shape;
-    int32 product = 1;
+    int64 product = 1;
     int unknown_index = -1;
     auto Svec = sizes.flat<int32>();
     for (int d = 0; d < num_dims; ++d) {
@@ -69,7 +69,7 @@
           errors::InvalidArgument("Reshape cannot infer the missing input size "
                                   "for an empty tensor unless all specified "
                                   "input sizes are non-zero"));
-      const int32 missing = input.NumElements() / product;
+      const int64 missing = input.NumElements() / product;
       OP_REQUIRES(
           context, product * missing == input.NumElements(),
           errors::InvalidArgument(


Clarify the need for calling tensorflow::port::InitMain() before using the rest of TensorFlow.

PiperOrigin-RevId: 219185259

--- tensorflow/core/platform/init_main.h
+++ tensorflow/core/platform/init_main.h
@@ -19,10 +19,10 @@
 namespace tensorflow {
 namespace port {

-// Platform-specific initialization routine that may be invoked by a
+// Platform-specific initialization routine that should be invoked by a
 // main() program that uses TensorFlow.
-//
-// Default implementation does nothing.
+// This performs necessary initialization on some platforms; TensorFlow
+// may not work unless it has been called.
 void InitMain(const char* usage, int* argc, char*** argv);

 }  // namespace port


Revert "Fix verilog/analysis/dependencies by re-adding Less VerilogSourceFile comparator"

This reverts commit 4d7d81445a8fa865dd8d0c4c265256e5fdbe6c7c.

--- verilog/analysis/dependencies.h
+++ verilog/analysis/dependencies.h
@@ -42,27 +42,8 @@
   // A set of strings, whose memory is owned outside of this data structure.
   using SymbolNameSet = std::set<absl::string_view, verible::StringViewCompare>;

-  // Comparator for ordering files for internal storage.
-  // Known limitation: this comparator won't work if you have multiple files
-  // with the same name referenced without a distinguishing path prefix.
-  struct FileCompare {
-    using is_transparent = void;  // hetergenous compare
-
-    static absl::string_view to_string_view(absl::string_view s) { return s; }
-    static absl::string_view to_string_view(const VerilogSourceFile& f) {
-      return f.ReferencedPath();
-    }
-    static absl::string_view to_string_view(const VerilogSourceFile* f) {
-      return f->ReferencedPath();
-    }
-
-    // T1/T2 could be any combination of:
-    // {const VerilogSourceFile&, absl::string_view}.
-    template <typename T1, typename T2>
-    bool operator()(T1 left, T2 right) const {
-      return to_string_view(left) < to_string_view(right);
-    }
-  };
+  // Sort by referenced file name.
+  using FileCompare = VerilogSourceFile::Less;

   // The outer key is a referencing file [R].
   // The inner key is a defining file [D].


ALSA: opti9xx: Fix conflicting driver object name

commit fb615499f0ad28ed74201c1cdfddf9e64e205424 upstream.

The recent commit to delay the release of kobject triggered NULL
dereferences of opti9xx drivers.  The cause is that all
snd-opti92x-ad1848, snd-opti92x-cs4231 and snd-opti93x drivers
register the PnP card driver with the very same name, and also
snd-opti92x-ad1848 and -cs4231 drivers register the ISA driver with
the same name, too.  When these drivers are built in, quick
"register-release-and-re-register" actions occur, and this results in
Oops because of the same name is assigned to the kobject.

The fix is simply to assign individual names.  As a bonus, by using
KBUILD_MODNAME, the patch reduces more lines than it adds.

The fix is based on the suggestion by Russell King.

Reported-and-tested-by: Fengguang Wu <24f7fe9d205c8a9f6ade0c2894e14303ca16087f@intel.com>
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- sound/isa/opti9xx/opti92x-ad1848.c
+++ sound/isa/opti9xx/opti92x-ad1848.c
@@ -173,11 +173,7 @@

 #endif	/* CONFIG_PNP */

-#ifdef OPTi93X
-#define DEV_NAME "opti93x"
-#else
-#define DEV_NAME "opti92x"
-#endif
+#define DEV_NAME KBUILD_MODNAME

 static char * snd_opti9xx_names[] = {
 	"unknown",
@@ -1168,7 +1164,7 @@

 static struct pnp_card_driver opti9xx_pnpc_driver = {
 	.flags		= PNP_DRIVER_RES_DISABLE,
-	.name		= "opti9xx",
+	.name		= DEV_NAME,
 	.id_table	= snd_opti9xx_pnpids,
 	.probe		= snd_opti9xx_pnp_probe,
 	.remove		= snd_opti9xx_pnp_remove,


ASoC: kirkwood: Fix module autoload for OF platform driver

This platform driver has a OF device ID table but the OF module
alias information is not created so module autoloading won't work.

Signed-off-by: Luis de Bethencourt <faea5242a00c52da62a0f00df168c199b7ab748d@debethencourt.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@kernel.org>


Adding documentation comments

Adding documentation comments

--- MDOverrides/MDPlugin.h
+++ MDOverrides/MDPlugin.h
@@ -37,6 +37,7 @@

 @protocol MDPlugin <NSObject>

+// You should have NSPrincipalClass set to your class name that implements this protocol
 // You should have CFBundleVersion in your info.plist set, and it should be an integer greater than 0 that increases for each version you send out
 // It would also be a good idea to set CFBundleShortVersionString, your humanized friendly version (eg: 1.0)

@@ -45,7 +46,7 @@
 // It is possible for a plug-in to have both of these keys set to true, and distinguish at run-time which mode it is being run through. At least one of these keys must be set to true.
 // In particular, if a plug-in has both keys set to true, then it will run through global mode if the plug-in is enabled by the user, otherwise it could run through map mode if it's disabled by the user and if a map requires the plug-in.

-// If you want to test a map-based plug-in without first submitting the map to the database, duplicate HaloMD_mods_list.json and rename the copy to HaloMD_mods_list_dev.json (in HaloMD's app support folder), add a new entry for your map and change its identifier and create a "plug-ins" key which is an array of plug-in name strings
+// If you want to test a map-based plug-in without first submitting the map to the database, duplicate HaloMD_mods_list.json and rename the copy to HaloMD_mods_list_dev.json (in HaloMD's app support folder), add a new entry for your map and change its identifier and create a "plug-ins" key which is an array of plug-in name strings. If you're on OS X 10.6 or below, do the same except with a plist instead of a json.

 typedef enum
 {
@@ -57,6 +58,7 @@
 // For all the methods below an auto release pool is set up.
 // If you use Obj-C code elsewhere like in a function hook, you will be responsible for setting one up yourself.

+// If you have a map based plug-in that is not meant to be run in global mode, you are either encouraged to: a) code-sign your plug-in preventing the info.plist from being modified, or b) release self and return nil
 - (id)initWithMode:(MDPluginMode)mode;

 // For the methods below via MDPluginMapMode, they will only be called if mapName requires the plug-in.


Adding  T0 font

Adding  T0 font

--- MID/lib/ui/Lcd240x64.h
+++ MID/lib/ui/Lcd240x64.h
@@ -505,6 +505,7 @@
         // u8g2_font_crox1cb_tf
         // u8g2_font_crox1h_tf
         // u8g2_font_crox1hb_tf
+//        lcd->setFont(u8g2_font_t0_15b_tf); // u8g2_font_unifont_t_cyrillic
         lcd->setFont(u8g2_opel_font_bold); // u8g2_font_unifont_t_cyrillic
         lcd->setFontRefHeightExtendedText();


Fix for application compiler warning: "PRId64" redefined.

git-svn-id: d1790394607e06e2b90be8c532f5c99d80a2d557@479 119443c7-1b9e-41f8-b6fc-b9c35fce742c

--- upnp/inc/UpnpGlobal.h
+++ upnp/inc/UpnpGlobal.h
@@ -95,7 +95,7 @@
 	 *
 	 * MSVC still does not know about this.
 	 */
-	#define PRId64 PRId64
+	/* #define PRId64 PRId64 */

 	/*!
 	 * \brief Supply the PRIzu printf() macro.


Permit use of dictionary files which have exact (same index and name) duplicates, but ensure the merged dictionary has unique entries

--- csrc/lib/ccn_extend_dict.c
+++ csrc/lib/ccn_extend_dict.c
@@ -34,13 +34,19 @@
     return (strcmp(ex->name, ey->name));
 }

+/* compare entries based on index, except that an entry with a NULL name
+ * field is always greater than a non-NULL name field, which allows us
+ * to bubble exact duplicates eliminated after the name sort to the end
+ */
 static int
 qsort_compare_dict_indices(const void *x, const void *y)
 {
     const struct ccn_dict_entry *ex = x;
     const struct ccn_dict_entry *ey = y;
-    if (ex->index == ey->index)
-        return (0);
+    if (ex->name == NULL)
+        return (ey->name == NULL) ? 0 : 1;
+    if (ey->name == NULL) return (-1);
+    if (ex->index == ey->index) return (0);
     return ((ex->index < ey->index) ? -1 : 1);
 }

@@ -171,14 +177,27 @@
     }
     ccn_charbuf_destroy(&enamebuf);

-    /* check for duplicate names then duplicate index values */
+    /* check for inconsistent duplicate names, mark exact duplicates for removal */
     qsort(ndd, ndc, sizeof(*ndd), qsort_compare_dict_names);
     for (i = 1; i < ndc; i++) {
         if (strcmp(ndd[i-1].name, ndd[i].name) == 0)
-            goto err;
-    }
+            if (ndd[i-1].index == ndd[i].index) {
+                free(ndd[i-1].name);
+                ndd[i-1].name = NULL;
+            } else
+                goto err;
+    }
+    /* check for inconsistent duplicate index values,
+     * trim the array when we reach the duplicates, marked above,
+     * which sorted to the end.
+     */
     qsort(ndd, ndc, sizeof(*ndd), qsort_compare_dict_indices);
     for (i = 1; i < ndc; i++) {
+        if (ndd[i].name == NULL) {
+            ndc = i;
+            ndd = realloc(ndd, sizeof(*ndd) * ndc);
+            break;
+        }
         if (ndd[i-1].index == ndd[i].index)
             goto err;
     }


make sure the correct diagoanl() function is called in trace()

--- Eigen/src/Core/Redux.h
+++ Eigen/src/Core/Redux.h
@@ -49,7 +49,7 @@
     MightVectorize = (int(Derived::Flags)&ActualPacketAccessBit)
                   && (ei_functor_traits<Func>::PacketAccess),
     MayLinearVectorize = MightVectorize && (int(Derived::Flags)&LinearAccessBit),
-    MaySliceVectorize  = MightVectorize && int(InnerMaxSize)>=3*PacketSize
+    MaySliceVectorize  = MightVectorize && int(InnerMaxSize)>=3*PacketSize
   };

 public:
@@ -58,7 +58,7 @@
                   : int(MaySliceVectorize)  ? int(SliceVectorizedTraversal)
                                             : int(DefaultTraversal)
   };
-
+
 private:
   enum {
     Cost = Derived::SizeAtCompileTime * Derived::CoeffReadCost
@@ -123,7 +123,7 @@
 };

 /*** vectorization ***/
-
+
 template<typename Func, typename Derived, int Start, int Length>
 struct ei_redux_vec_unroller
 {
@@ -223,7 +223,7 @@
       for(int index = alignedStart + packetSize; index < alignedEnd; index += packetSize)
         packet_res = func.packetOp(packet_res, mat.template packet<alignment>(index));
       res = func.predux(packet_res);
-
+
       for(int index = 0; index < alignedStart; ++index)
         res = func(res,mat.coeff(index));

@@ -265,7 +265,7 @@
         for(int i=0; i<packetedInnerSize; i+=int(packetSize))
           packet_res = func.packetOp(packet_res, mat.template packet<Unaligned>
                                                  (isRowMajor?j:i, isRowMajor?i:j));
-
+
       res = func.predux(packet_res);
       for(int j=0; j<outerSize; ++j)
         for(int i=packetedInnerSize; i<innerSize; ++i)
@@ -382,7 +382,7 @@
 EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar
 MatrixBase<Derived>::trace() const
 {
-  return diagonal().sum();
+  return derived().diagonal().sum();
 }

 #endif // EIGEN_REDUX_H


fix bug in sliced redux

fix bug in sliced redux

--- Eigen/src/Core/Redux.h
+++ Eigen/src/Core/Redux.h
@@ -257,7 +257,7 @@
     {
       PacketScalar packet_res = mat.template packet<Unaligned>(0,0);
       for(int j=0; j<outerSize; ++j)
-        for(int i=0; i<packetedInnerSize; i+=int(packetSize))
+        for(int i=(j==0?packetSize:0); i<packetedInnerSize; i+=int(packetSize))
           packet_res = func.packetOp(packet_res, mat.template packetByOuterInner<Unaligned>(j,i));

       res = func.predux(packet_res);


update copyright notice / whitespace

update copyright notice / whitespace


attempt to make python based testing system with fork and exec.  while i learned a lot, I'm way overcomplicating this.


Reverted CopyAlpha fix and fixed the bug differently.

--- MagickCore/composite.c
+++ MagickCore/composite.c
@@ -552,9 +552,8 @@
   if (IsGrayColorspace(image->colorspace) != MagickFalse)
     (void) SetImageColorspace(image,sRGBColorspace,exception);
   (void) SetImageColorspace(composite_image,image->colorspace,exception);
-  if (image->alpha_trait == UndefinedPixelTrait)
-    (void) SetImageAlphaChannel(image,SetAlphaChannel,exception);
-  if (composite_image->alpha_trait == UndefinedPixelTrait)
+  if ((image->alpha_trait != UndefinedPixelTrait) &&
+      (composite_image->alpha_trait == UndefinedPixelTrait))
     (void) SetImageAlphaChannel(composite_image,SetAlphaChannel,exception);
 if (0)
   if ((compose == OverCompositeOp) || (compose == SrcOverCompositeOp))
@@ -1524,8 +1523,11 @@
           channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if (composite_traits == UndefinedPixelTrait)
-          continue;
+        if ((composite_traits == UndefinedPixelTrait) &&
+             (((compose != CopyAlphaCompositeOp) &&
+               (compose != ChangeMaskCompositeOp)) ||
+              (channel != AlphaPixelChannel)))
+            continue;
         /*
           Sc: source color.
           Dc: destination color.
@@ -1614,7 +1616,7 @@
               }
               case CopyAlphaCompositeOp:
               {
-                if (Sa == 1.0)
+                if (composite_traits == UndefinedPixelTrait)
                   pixel=GetPixelIntensity(composite_image,p);
                 else
                   pixel=QuantumRange*Sa;


Update change log

git-svn-id: 5c8b60fcb9320cccfd2f497bdea85b37ac3f2028@2332 fa1542d4-bde8-0310-ad64-8ed1123d492a

--- FilePlugin/sqFilePluginBasicPrims.c
+++ FilePlugin/sqFilePluginBasicPrims.c
@@ -9,6 +9,7 @@
 *   RCSID:   $Id$
 *
 *   NOTES: See change log below.
+*   	2010-12-28 dtl add sqFileStdioHandlesInto() adapted from Cog branch
 *	2008-08-29 bf  add stdin/stdout/stderr support
 *	2005-03-26 IKP fix unaligned accesses to file[Size] members
 * 	2004-06-10 IKP 64-bit cleanliness


Syntax error checks 'f' to 'l'

Syntax error checks 'f' to 'l'

--- MagickWand/operation.c
+++ MagickWand/operation.c
@@ -1082,9 +1082,13 @@
       if (LocaleCompare("gravity",option+1) == 0)
         {
           /* SyncImageSettings() used to set per-image attribute. */
-          (void) SetImageOption(_image_info,option+1,ArgOption("none"));
-          _draw_info->gravity=(GravityType) ParseCommandOption(
-                   MagickGravityOptions,MagickFalse,ArgOption("none"));
+          arg1 = ArgOption("none");
+          parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1);
+          if (parse < 0)
+            CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType",
+                                      option,arg1);
+          (void) SetImageOption(_image_info,option+1,arg1);
+          _draw_info->gravity=(GravityType) parse;
           break;
         }
       if (LocaleCompare("green-primary",option+1) == 0)
@@ -1093,6 +1097,8 @@
              SyncImageSettings() used to set per-image attribute.
              Used directly by many coders
           */
+          if (IfSetOption && IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           (void) SetImageOption(_image_info,option+1,ArgOption("0.0"));
           break;
         }
@@ -1106,7 +1112,12 @@
              and for image profile call to AcquireTransformThreadSet()
              SyncImageSettings() used to set per-image attribute.
           */
-          (void) SetImageOption(_image_info,option+1,ArgOption("undefined"));
+          arg1 = ArgOption("indefined");
+          parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1);
+          if (parse < 0)
+            CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType",
+                                      option,arg1);
+          (void) SetImageOption(_image_info,option+1,arg1);
           break;
         }
       if (LocaleCompare("interlace",option+1) == 0)
@@ -1114,13 +1125,19 @@
           /* _image_info is directly used by coders (so why an image setting?)
              SyncImageSettings() used to set per-image attribute.
           */
-          (void) SetImageOption(_image_info,option+1,ArgOption("undefined"));
-          _image_info->interlace=(InterlaceType) ParseCommandOption(
-                MagickInterlaceOptions,MagickFalse,ArgOption("undefined"));
+          arg1 = ArgOption("undefined");
+          parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1);
+          if (parse < 0)
+            CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType",
+                                      option,arg1);
+          _image_info->interlace=(InterlaceType) parse;
+          (void) SetImageOption(_image_info,option+1,arg1);
           break;
         }
       if (LocaleCompare("interline-spacing",option+1) == 0)
         {
+          if (IfSetOption && IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           (void) SetImageOption(_image_info,option+1, ArgOption(NULL));
           _draw_info->interline_spacing=StringToDouble(ArgOption("0"),
                (char **) NULL);
@@ -1129,11 +1146,18 @@
       if (LocaleCompare("interpolate",option+1) == 0)
         {
           /* SyncImageSettings() used to set per-image attribute. */
-          (void) SetImageOption(_image_info,option+1,ArgOption("undefined"));
+          arg1 = ArgOption("undefined");
+          parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1);
+          if (parse < 0)
+            CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod",
+                                      option,arg1);
+          (void) SetImageOption(_image_info,option+1,arg1);
           break;
         }
       if (LocaleCompare("interword-spacing",option+1) == 0)
         {
+          if (IfSetOption && IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           (void) SetImageOption(_image_info,option+1, ArgOption(NULL));
           _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL);
           break;
@@ -1144,6 +1168,8 @@
     {
       if (LocaleCompare("kerning",option+1) == 0)
         {
+          if (IfSetOption && IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
           _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL);
           break;
@@ -1160,14 +1186,20 @@
         }
       if (LocaleCompare("log",option+1) == 0)
         {
-          if (IfSetOption)
+          if (IfSetOption) {
+            if ((strchr(arg1,'%') == (char *) NULL))
+              CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
             (void) SetLogFormat(arg1);
+          }
           break;
         }
       if (LocaleCompare("loop",option+1) == 0)
         {
           /* SyncImageSettings() used to set per-image attribute. */
-          (void) SetImageOption(_image_info,option+1,ArgOption("0"));
+          arg1=ArgOption("0");
+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
+          (void) SetImageOption(_image_info,option+1,arg1);
           break;
         }
       CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
@@ -1331,6 +1363,8 @@
              Used by many coders
              SyncImageSettings() used to set per-image attribute.
           */
+          if (IfSetOption && IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           (void) SetImageOption(_image_info,option+1,ArgOption("0.0"));
           break;
         }
@@ -1729,6 +1763,7 @@
         }
       if (LocaleCompare("adaptive-resize",option+1) == 0)
         {
+          /* FUTURE: Roll into a resize special operator */
           if (IsGeometry(arg1) == MagickFalse)
             CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
@@ -2236,7 +2271,7 @@
                /* Special Case - Argument is actually a resize geometry!
                ** Convert that to an appropriate distortion argument array.
                ** FUTURE: make a separate special resize operator
-               */
+                    Roll into a resize special operator */
                if (IsGeometry(arg2) == MagickFalse)
                  CLIWandExceptArgBreak(OptionError,"InvalidGeometry",
                                            option,arg2);
@@ -2505,6 +2540,8 @@
     {
       if (LocaleCompare("gamma",option+1) == 0)
         {
+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           if (IfNormalOp)
             (void) GammaImage(_image,StringToDouble(arg1,(char **) NULL),
                  _exception);
@@ -2515,6 +2552,8 @@
       if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
           (LocaleCompare("gaussian",option+1) == 0))
         {
+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           flags=ParseGeometry(arg1,&geometry_info);
           if ((flags & SigmaValue) == 0)
             geometry_info.sigma=1.0;
@@ -2526,7 +2565,7 @@
         {
           /*
             Record Image offset for composition. (A Setting)
-            Resize last _image. (ListOperator)
+            Resize last _image. (ListOperator)  -- DEPRECIATE
             FUTURE: Why if no 'offset' does this resize ALL images?
             Also why is the setting recorded in the IMAGE non-sense!
           */
@@ -2536,6 +2575,8 @@
                 _image->geometry=DestroyString(_image->geometry);
               break;
             }
+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
           if (((flags & XValue) != 0) || ((flags & YValue) != 0))
             (void) CloneString(&_image->geometry,arg1);
@@ -2580,6 +2621,8 @@
         }
       if (LocaleCompare("implode",option+1) == 0)
         {
+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           (void) ParseGeometry(arg1,&geometry_info);
           new_image=ImplodeImage(_image,geometry_info.rho,
             _image->interpolate,_exception);
@@ -2587,6 +2630,10 @@
         }
       if (LocaleCompare("interpolative-resize",option+1) == 0)
         {
+          /* FUTURE: New to IMv7
+               Roll into a resize special operator */
+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
           new_image=InterpolativeResizeImage(_image,geometry.width,
                geometry.height,_image->interpolate,_exception);
@@ -2598,6 +2645,8 @@
     {
       if (LocaleCompare("lat",option+1) == 0)
         {
+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           flags=ParseGeometry(arg1,&geometry_info);
           if ((flags & PercentValue) != 0)
             geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
@@ -2616,6 +2665,8 @@
           MagickStatusType
             flags;

+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           flags=ParseGeometry(arg1,&geometry_info);
           black_point=geometry_info.rho;
           white_point=(MagickRealType) QuantumRange;
@@ -2685,6 +2736,8 @@
           MagickStatusType
             flags;

+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           flags=ParseGeometry(arg1,&geometry_info);
           black_point=geometry_info.rho;
           white_point=(MagickRealType) _image->columns*_image->rows;
@@ -2703,6 +2756,9 @@
         }
       if (LocaleCompare("liquid-rescale",option+1) == 0)
         {
+          /* FUTURE: Roll into a resize special operator */
+          if (IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
           if ((flags & XValue) == 0)
             geometry.x=1;
@@ -3112,6 +3168,7 @@
     {
       if (LocaleCompare("sample",option+1) == 0)
         {
+          /* FUTURE: Roll into a resize special operator */
           (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
           new_image=SampleImage(_image,geometry.width,geometry.height,
             _exception);
@@ -3119,6 +3176,7 @@
         }
       if (LocaleCompare("scale",option+1) == 0)
         {
+          /* FUTURE: Roll into a resize special operator */
           (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
           new_image=ScaleImage(_image,geometry.width,geometry.height,
             _exception);
@@ -3565,7 +3623,7 @@
 %
 %    o arg1, arg2: optional argument strings to the operation
 %
-% NOTE: only "limit" currently uses two arguments.
+% NOTE: only "limit" uses two arguments.
 %
 % Example usage...
 %
@@ -3864,6 +3922,8 @@
           ssize_t
             index;

+          if (IfNormalOp && IsGeometry(arg1) == MagickFalse)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
           index=0;
           insert_image=RemoveLastImageFromList(&_images);
           if (IfNormalOp)
@@ -3877,11 +3937,7 @@
             {
                index_image=GetImageFromList(_images,index-1);
                if (index_image == (Image *) NULL)
-                 {
-                   (void) ThrowMagickException(_exception,GetMagickModule(),
-                     OptionError,"NoSuchImage","'%s'",arg1);
-                   break;
-                 }
+                 CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1);
               InsertImageInList(&index_image,insert_image);
             }
           _images=GetFirstImageInList(index_image);
@@ -3893,12 +3949,11 @@
     {
       if (LocaleCompare("layers",option+1) == 0)
         {
-          ImageLayerMethod
-            method;
-
-          method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
-            MagickFalse,arg1);
-          switch (method)
+          parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1);
+          if ( parse < 0 )
+            CLIWandExceptArgBreak(OptionError,"UnrecognizedLayerMethod",
+                 option,arg1);
+          switch ((ImageLayerMethod) parse)
           {
             case CoalesceLayer:
             {
@@ -3910,7 +3965,8 @@
             case CompareOverlayLayer:
             default:
             {
-              new_images=CompareImagesLayers(_images,method,_exception);
+              new_images=CompareImagesLayers(_images,(ImageLayerMethod) parse,
+                   _exception);
               break;
             }
             case MergeLayer:
@@ -3918,7 +3974,8 @@
             case MosaicLayer:
             case TrimBoundsLayer:
             {
-              new_images=MergeImageLayers(_images,method,_exception);
+              new_images=MergeImageLayers(_images,(ImageLayerMethod) parse,
+                   _exception);
               break;
             }
             case DisposeLayer:
@@ -4038,15 +4095,14 @@
           MagickSizeType
             limit;

-          ResourceType
-            type;
-
-          type=(ResourceType) ParseCommandOption(MagickResourceOptions,
-            MagickFalse,arg1);
           limit=MagickResourceInfinity;
+          parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1);
+          if ( parse < 0 )
+            CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType",
+                 option,arg1);
           if (LocaleCompare("unlimited",arg2) != 0)
             limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0);
-          (void) SetMagickResourceLimit(type,limit);
+          (void) SetMagickResourceLimit((ResourceType)parse,limit);
           break;
         }
       CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
@@ -4533,6 +4589,10 @@
         list;

       list=ParseCommandOption(MagickListOptions,MagickFalse, arg1);
+      if ( list < 0 ) {
+        CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1);
+        return;
+      }
       switch (list)
       {
         case MagickCoderOptions:


Allow NFDS() to be defined on everything except AIX, but don't proto-type select() on HPUX9.

--- src/condor_includes/condor_fdset.h
+++ src/condor_includes/condor_fdset.h
@@ -50,8 +50,11 @@
 extern "C" {
 #endif

+#if !defined(AIX32) && !defined(HPUX9)
+int select (int , fd_set *, fd_set *, fd_set *, struct timeval *);
+#endif
+
 #if !defined(AIX32)
-int select (int , fd_set *, fd_set *, fd_set *, struct timeval *);
 #define NFDS(x) (x)
 #endif


Qcom/Library/QTimerLib: implement performance counter

--- Qcom/Library/QTimerLib/QTimerLib.c
+++ Qcom/Library/QTimerLib/QTimerLib.c
@@ -2,7 +2,7 @@
 #include <Library/LKEnvLib.h>
 #include <Library/TimerLib.h>
 #include <Library/DebugLib.h>
-#include <Library/QcomDxeTimerLib.h>
+#include <Library/BaseLib.h>

 #include "qtimer_p.h"
 #include "qtimer_mmap_hw.h"
@@ -97,8 +97,7 @@
   VOID
   )
 {
-  ASSERT (FALSE);
-  return 0;
+  return qtimer_get_phy_timer_cnt();
 }

 UINT64
@@ -108,9 +107,15 @@
   OUT      UINT64                    *EndValue     OPTIONAL
   )
 {
-  ASSERT (FALSE);
+  if (StartValue != NULL) {
+    *StartValue = 0;
+  }

-  return (UINT64)(-1);
+  if (EndValue != NULL) {
+    *EndValue = 0xFFFFFFFFFFFFFFULL;
+  }
+
+  return (UINT64)qtimer_get_frequency();
 }

 UINT64
@@ -119,6 +124,24 @@
   IN      UINT64                     Ticks
   )
 {
-  ASSERT (FALSE);
-  return 0;
+  UINT64  NanoSeconds;
+  UINT32  Remainder;
+  UINT64  Frequency;
+
+  Frequency = GetPerformanceCounterProperties(NULL, NULL);
+
+  //
+  //          Ticks
+  // Time = --------- x 1,000,000,000
+  //        Frequency
+  //
+  NanoSeconds = MultU64x32 (DivU64x32Remainder (Ticks, Frequency, &Remainder), 1000000000u);
+
+  //
+  // Frequency < 0x100000000, so Remainder < 0x100000000, then (Remainder * 1,000,000,000)
+  // will not overflow 64-bit.
+  //
+  NanoSeconds += DivU64x32 (MultU64x32 ((UINT64) Remainder, 1000000000u), Frequency);
+
+  return NanoSeconds;
 }


Set socket options correctly for the accepted socket.

Closes #2722

--- bin/varnishd/cache/cache_acceptor.c
+++ bin/varnishd/cache/cache_acceptor.c
@@ -221,17 +221,16 @@
 }

 static void
-vca_tcp_opt_test(const struct listen_sock *ls)
-{
-	int i, n, sock;
+vca_tcp_opt_test(const int sock, const unsigned uds)
+{
+	int i, n;
 	struct tcp_opt *to;
 	socklen_t l;
 	void *ptr;

-	sock = ls->sock;
 	for (n = 0; n < n_tcp_opts; n++) {
 		to = &tcp_opts[n];
-		if (to->iponly && ls->uds)
+		if (to->iponly && uds)
 			continue;
 		to->need = 1;
 		ptr = calloc(1, to->sz);
@@ -247,15 +246,14 @@
 }

 static void
-vca_tcp_opt_set(const struct listen_sock *ls, int force)
-{
-	int n, sock;
+vca_tcp_opt_set(const int sock, const unsigned uds, const int force)
+{
+	int n;
 	struct tcp_opt *to;

-	sock = ls->sock;
 	for (n = 0; n < n_tcp_opts; n++) {
 		to = &tcp_opts[n];
-		if (to->iponly && ls->uds)
+		if (to->iponly && uds)
 			continue;
 		if (to->need || force) {
 			VTCP_Assert(setsockopt(sock,
@@ -426,10 +424,10 @@
 	wrk->stats->sess_conn++;

 	if (need_test) {
-		vca_tcp_opt_test(wa->acceptlsock);
+		vca_tcp_opt_test(sp->fd, wa->acceptlsock->uds);
 		need_test = 0;
 	}
-	vca_tcp_opt_set(wa->acceptlsock, 0);
+	vca_tcp_opt_set(sp->fd, wa->acceptlsock->uds, 0);

 	req = Req_New(wrk, sp);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
@@ -607,7 +605,7 @@
 				if (ls->sock == -2)
 					continue;	// VCA_Shutdown
 				assert (ls->sock > 0);
-				vca_tcp_opt_set(ls, 1);
+				vca_tcp_opt_set(ls->sock, ls->uds, 1);
 			}
 			AZ(pthread_mutex_unlock(&shut_mtx));
 		}
@@ -646,7 +644,7 @@
 			    ls->endpoint, strerror(errno));
 			return;
 		}
-		vca_tcp_opt_set(ls, 1);
+		vca_tcp_opt_set(ls->sock, ls->uds, 1);
 		if (cache_param->accept_filter) {
 			int i;
 			i = VTCP_filter_http(ls->sock);


Silence a Flexelint warning

Silence a Flexelint warning

--- bin/varnishd/storage/storage_file.c
+++ bin/varnishd/storage/storage_file.c
@@ -227,7 +227,8 @@
 	b = bytes / sc->pagesize;
 	if (b >= NBUCKET)
 		b = NBUCKET - 1;
-	for (sp = NULL; b < NBUCKET - 1; b++) {
+	sp = NULL;
+	for (; b < NBUCKET - 1; b++) {
 		sp = VTAILQ_FIRST(&sc->free[b]);
 		if (sp != NULL)
 			break;


[#1704] sortObjInfo put non hier matching objinfos into the old queue which caused issues downstream for replication

--- iRODS/server/core/src/dataObjOpr.c
+++ iRODS/server/core/src/dataObjOpr.c
@@ -456,7 +456,7 @@
         }

         else if(resc_hier != NULL && !hier_match) {
-            queDataObjInfo (oldCacheInfo, tmpDataObjInfo, 1, topFlag);
+            queDataObjInfo( currentCacheInfo, tmpDataObjInfo, 1, 0 );
         }

         // rescClassInx = tmpDataObjInfo->rescInfo->rescClassInx;


Add definition of _DEFAULT_SOURCE.

Add definition of _DEFAULT_SOURCE.

Since glibc version 2.20, _SVID_SOURCE is deprecated, see
'man 7 feature_test_macros'. To be able to compile this code without compiler
warnings in new and old glibc versions, both _DEFAULT_SOURCE and _SVID_SOURCE
must be defined.

--- vpi/sys_scanf.c
+++ vpi/sys_scanf.c
@@ -20,6 +20,7 @@
 /* round() is ISO C99 from math.h. This define should enable it. */
 # define _ISOC99_SOURCE 1
 # define _SVID_SOURCE 1
+# define _DEFAULT_SOURCE 1

 # include  "sys_priv.h"
 # include  <ctype.h>


Add spin-wait pause intrinsic for Windows x64 platform.

Change-Id: I7504370c67a3c551627c6bb7e67c65f83d88b78e

--- vpx_ports/x86.h
+++ vpx_ports/x86.h
@@ -151,8 +151,8 @@
     __asm__ __volatile__ ("pause \n\t")
 #else
 #if ARCH_X86_64
-/* No pause intrinsic for windows x64 */
-#define x86_pause_hint()
+#define x86_pause_hint()\
+    _mm_pause();
 #else
 #define x86_pause_hint()\
     __asm pause


Add movement 'W'

Add movement 'W'

--- config.def.h
+++ config.def.h
@@ -112,6 +112,7 @@
 	{ { NONE('b')               }, movement, { .i = MOVE_WORD_START_PREV   } },
 	{ { NONE('B')               }, movement, { .i = MOVE_WORD_START_PREV   } },
 	{ { NONE('w')               }, movement, { .i = MOVE_WORD_START_NEXT   } },
+	{ { NONE('W')               }, movement, { .i = MOVE_WORD_START_NEXT   } },
 	{ { NONE('g'), NONE('e')    }, movement, { .i = MOVE_WORD_END_PREV     } },
 	{ { NONE('e')               }, movement, { .i = MOVE_WORD_END_NEXT     } },
 	{ { NONE('E')               }, movement, { .i = MOVE_WORD_END_NEXT     } },


tools: rinaperf: use packed attribute for message structs

--- user/tools/rinaperf.c
+++ user/tools/rinaperf.c
@@ -62,17 +62,17 @@
 struct worker;

 struct rp_config_msg {
+    uint64_t cnt;       /* packet/transaction count for the test
+                         * (0 means infinite) */
     uint32_t opcode;    /* opcode: ping, perf, rr ... */
     uint32_t ticket;    /* valid with RP_OPCODE_DATAFLOW */
     uint32_t size;      /* packet size in bytes */
-    uint64_t cnt;       /* packet/transaction count for the test
-                         * (0 means infinite) */
-};
+} __attribute__((packed));

 struct rp_ticket_msg {
     uint32_t ticket; /* ticket allocated by the server for the
                       * client to identify the data flow */
-};
+} __attribute__((packed));

 struct rp_result_msg {
     uint64_t cnt; /* number of packets or completed transactions
@@ -80,7 +80,7 @@
     uint64_t pps; /* average packet rate measured by the sender or receiver */
     uint64_t bps; /* average bandwidth measured by the sender or receiver */
     uint64_t latency; /* in nanoseconds */
-};
+} __attribute__((packed));

 typedef int (*perf_fn_t)(struct worker *);
 typedef void (*report_fn_t)(struct rp_result_msg *snd,


Fix sigabort on using high-precision tick generator in macOS

--- Resources/Native/NativeApi-macOS.c
+++ Resources/Native/NativeApi-macOS.c
@@ -30,6 +30,8 @@
         usleep(tickGeneratorInfo->interval * 1000);
         tickGeneratorInfo->callback();
     }
+
+	free(data);

     return NULL;
 }
@@ -55,9 +57,9 @@

     tickGeneratorInfo->active = 0;

-    pthread_join(tickGeneratorInfo->thread, NULL);
-
-    free(info);
+    //pthread_join(tickGeneratorInfo->thread, NULL);
+
+    //free(info);

     return TG_STOPRESULT_OK;
 }


* buckets/ssl_buckets.c:
  (serf_ssl_cert_certificate): fix signed-ness of the string to copy

git-svn-id: 683495cb1553624b05a54e2ba9533425f69cf277@1591 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845

--- buckets/ssl_buckets.c
+++ buckets/ssl_buckets.c
@@ -1469,7 +1469,8 @@

             switch (nm->type) {
             case GEN_DNS:
-                p = apr_pstrmemdup(pool, nm->d.ia5->data, nm->d.ia5->length);
+                p = apr_pstrmemdup(pool, (const char *)nm->d.ia5->data,
+                                   nm->d.ia5->length);
                 break;
             default:
                 /* Don't know what to do - skip. */


added cctype include

added cctype include

--- source/adios2/toolkit/query/Util.h
+++ source/adios2/toolkit/query/Util.h
@@ -3,7 +3,7 @@

 #include <ios>      //std::ios_base::failure
 #include <iostream> //std::cout
-
+#include <cctype>
 #include <stdexcept>
 #include <string>
 #include <vector>


Create a discrete sampling method

Create a discrete sampling method

--- source/core/math/uniform_sampler.h
+++ source/core/math/uniform_sampler.h
@@ -47,6 +47,10 @@
 		return float2(NextFloat(), NextFloat());
 	}

+	uint NextDiscrete(uint range) {
+		return range * NextFloat();
+	}
+
 private:
 	// Note: Could replace this with memcpy, which gcc optimizes to the same assembly
 	// as the code below. I'm not sure how other compiler treat it though, since it's


Fixed indentation of macro continuation characters (\)

--- source/cut/include/cut/framework.h
+++ source/cut/include/cut/framework.h
@@ -10,25 +10,24 @@
 #include "cut/unit-test.h"
 #include "cut/assert.h"

-
-#define CUT_GROUP(groupName) class UnitTestGroup_##groupName :								\
-	public ::cut::UnitTestGroup																								 \
-{																																								 \
-public:																																					 \
-	UnitTestGroup_##groupName() :																									 \
-		::cut::UnitTestGroup(#groupName){}																				\
-};																																								\
+#define CUT_GROUP(groupName) class UnitTestGroup_##groupName : \
+	public ::cut::UnitTestGroup                                \
+{                                                              \
+public:                                                        \
+	UnitTestGroup_##groupName() :                              \
+		::cut::UnitTestGroup(#groupName){}                     \
+};                                                             \
 UnitTestGroup_##groupName g_unitTestGroup_##groupName

-#define CUT_TEST(groupName, className) class UnitTest_##groupName##_##className :	\
-	public ::cut::IUnitTest																													\
-{																																											\
-public:																																								\
-	UnitTest_##groupName##_##className()																								 \
-	{																																										\
-		g_unitTestGroup_##groupName.registerUnitTest(#className, this);										\
-	}																																										\
-	virtual void run() override;																												 \
-};																																										 \
-UnitTest_##groupName##_##className g_unitTest_##groupName##_##className;							 \
+#define CUT_TEST(groupName, className) class UnitTest_##groupName##_##className : \
+	public ::cut::IUnitTest                                                       \
+{                                                                                \
+public:                                                                           \
+	UnitTest_##groupName##_##className()                                          \
+	{                                                                             \
+		g_unitTestGroup_##groupName.registerUnitTest(#className, this);           \
+	}                                                                             \
+	virtual void run() override;                                                  \
+};                                                                                \
+UnitTest_##groupName##_##className g_unitTest_##groupName##_##className;          \
 void UnitTest_##groupName##_##className::run()


cleanups

cleanups

--- kernels/geometry/oriented_curve_intersector.h
+++ kernels/geometry/oriented_curve_intersector.h
@@ -781,42 +781,7 @@
           return intersect(v,Interval1f(0.0f,1.0f));
         }

-        __forceinline void solve_uv(BBox1f cu, BBox1f cv, const TensorLinearCubicBezierSurface2fa& curve2)
-        {
-          const Vec2fa du = curve2.axis_u();
-          const Vec2fa dv = curve2.axis_v();
-
-          const TensorLinearCubicBezierSurface1f curve1v = curve2.xfm(dv);
-          LinearBezierCurve<Interval1f> curve0v = curve1v.reduce_u();
-          if (!curve0v.hasRoot()) return;
-
-          const Interval1f v = bezier_clipping(curve0v);
-          if (isEmpty(v)) return;
-          TensorLinearCubicBezierSurface2fa curve2a = curve2.clip_v(v);
-          cv = BBox1f(lerp(cv.lower,cv.upper,v.lower),lerp(cv.lower,cv.upper,v.upper));
-
-          const TensorLinearCubicBezierSurface1f curve1u = curve2a.xfm(du);
-          CubicBezierCurve<Interval1f> curve0u = curve1u.reduce_v();
-          int roots = curve0u.maxRoots();
-          if (roots == 0) return;
-
-          if (roots == 1)
-          {
-            const Interval1f u = bezier_clipping(curve0u);
-            if (isEmpty(u)) return;
-            TensorLinearCubicBezierSurface2fa curve2b = curve2a.clip_u(u);
-            cu = BBox1f(lerp(cu.lower,cu.upper,u.lower),lerp(cu.lower,cu.upper,u.upper));
-            solve(cu,cv,curve2b);
-            return;
-          }
-
-          TensorLinearCubicBezierSurface2fa curve2l, curve2r;
-          curve2a.split_u(curve2l,curve2r);
-          solve(BBox1f(cu.lower,cu.center()),cv,curve2l);
-          solve(BBox1f(cu.center(),cu.upper),cv,curve2r);
-        }
-
-        void solve(BBox1f cu, BBox1f cv, const TensorLinearCubicBezierSurface2fa& curve2)
+        void solve_bezier_clipping(BBox1f cu, BBox1f cv, const TensorLinearCubicBezierSurface2fa& curve2)
         {
           BBox2fa bounds = curve2.bounds();
           if (bounds.upper.x < 0.0f) return;
@@ -836,14 +801,45 @@
               isHit |= epilog(hit);
             }
             return;
-          }
-          solve_uv(cu,cv,curve2);
-        }
-
-        bool solve()
+          }
+
+          const Vec2fa du = curve2.axis_u();
+          const Vec2fa dv = curve2.axis_v();
+
+          const TensorLinearCubicBezierSurface1f curve1v = curve2.xfm(dv);
+          LinearBezierCurve<Interval1f> curve0v = curve1v.reduce_u();
+          if (!curve0v.hasRoot()) return;
+
+          const Interval1f v = bezier_clipping(curve0v);
+          if (isEmpty(v)) return;
+          TensorLinearCubicBezierSurface2fa curve2a = curve2.clip_v(v);
+          cv = BBox1f(lerp(cv.lower,cv.upper,v.lower),lerp(cv.lower,cv.upper,v.upper));
+
+          const TensorLinearCubicBezierSurface1f curve1u = curve2a.xfm(du);
+          CubicBezierCurve<Interval1f> curve0u = curve1u.reduce_v();
+          int roots = curve0u.maxRoots();
+          if (roots == 0) return;
+
+          if (roots == 1)
+          {
+            const Interval1f u = bezier_clipping(curve0u);
+            if (isEmpty(u)) return;
+            TensorLinearCubicBezierSurface2fa curve2b = curve2a.clip_u(u);
+            cu = BBox1f(lerp(cu.lower,cu.upper,u.lower),lerp(cu.lower,cu.upper,u.upper));
+            solve_bezier_clipping(cu,cv,curve2b);
+            return;
+          }
+
+          TensorLinearCubicBezierSurface2fa curve2l, curve2r;
+          curve2a.split_u(curve2l,curve2r);
+          solve_bezier_clipping(BBox1f(cu.lower,cu.center()),cv,curve2l);
+          solve_bezier_clipping(BBox1f(cu.center(),cu.upper),cv,curve2r);
+        }
+
+        bool solve_bezier_clipping()
         {
           TensorLinearCubicBezierSurface2fa curve2 = curve3d.xfm(space.vx,space.vy,ray.org);
-          solve(BBox1f(0.0f,1.0f),BBox1f(0.0f,1.0f),curve2);
+          solve_bezier_clipping(BBox1f(0.0f,1.0f),BBox1f(0.0f,1.0f),curve2);
           return isHit;
         }

@@ -1172,7 +1168,7 @@
         CubicBezierCurve3fa L(v0-d0,v1-d1,v2-d2,v3-d3);
         CubicBezierCurve3fa R(v0+d0,v1+d1,v2+d2,v3+d3);
         TensorLinearCubicBezierSurface3fa curve(L,R);
-        //return TensorLinearCubicBezierSurfaceIntersector<Epilog>(ray,curve,epilog).solve();
+        //return TensorLinearCubicBezierSurfaceIntersector<Epilog>(ray,curve,epilog).solve_bezier_clipping();
         return TensorLinearCubicBezierSurfaceIntersector<Epilog>(ray,curve,epilog).solve_newton_raphson_main();
       }
     };


updates

updates

--- kernels/geometry/oriented_curve_intersector.h
+++ kernels/geometry/oriented_curve_intersector.h
@@ -1011,27 +1011,30 @@
           if (none(valid)) return;
 #endif

-          Vec2vfx du = subcurves.axis_u();
-          DBG(tab(depth); PRINT(du));
-          Vec2vfx ndu = Vec2vfx(-du.y,du.x);
-          BBox<vfloatx> boundsu = subcurves.vbounds(ndu);
-          DBG(tab(depth); PRINT(boundsu));
-          valid &= boundsu.lower <= eps;
-          valid &= boundsu.upper >= -eps;
-          DBG(tab(depth); PRINT(valid));
-          asm("//solve_newton_raphson_wide_f");
-          if (none(valid)) return;
-
-          Vec2vfx dv = subcurves.axis_v();
-          DBG(tab(depth); PRINT(dv));
-          Vec2vfx ndv = Vec2vfx(-dv.y,dv.x);
-          BBox<vfloatx> boundsv = subcurves.vbounds(ndv);
-          valid &= boundsv.lower <= eps;
-          valid &= boundsv.upper >= -eps;
-          DBG(tab(depth); PRINT(valid));
-          asm("//solve_newton_raphson_wide_g");
-          if (none(valid)) return;
-
+          //if (__popcnt(movemask(valid)) > 1)
+          {
+            Vec2vfx du = subcurves.axis_u();
+            DBG(tab(depth); PRINT(du));
+            Vec2vfx ndu = Vec2vfx(-du.y,du.x);
+            BBox<vfloatx> boundsu = subcurves.vbounds(ndu);
+            DBG(tab(depth); PRINT(boundsu));
+            valid &= boundsu.lower <= eps;
+            valid &= boundsu.upper >= -eps;
+            DBG(tab(depth); PRINT(valid));
+            asm("//solve_newton_raphson_wide_f");
+            if (none(valid)) return;
+
+            Vec2vfx dv = subcurves.axis_v();
+            DBG(tab(depth); PRINT(dv));
+            Vec2vfx ndv = Vec2vfx(-dv.y,dv.x);
+            BBox<vfloatx> boundsv = subcurves.vbounds(ndv);
+            valid &= boundsv.lower <= eps;
+            valid &= boundsv.upper >= -eps;
+            DBG(tab(depth); PRINT(valid));
+            asm("//solve_newton_raphson_wide_g");
+            if (none(valid)) return;
+          }
+
           size_t mask = movemask(valid);
           while (mask)
           {


Int16Buffer: fix overzealous spurious update suppression logic

The Int16Buffer class will only mark the data as dirty
(i.e. have hasUpdatedData() return true) when the received data value
is actually different from the last value that was seen.

The previous logic failed to take into account the uninitialized state,
where the (zero) value stored in the data member variable was not the
result of a previous update from DCS-BIOS, but the default after
program startup.

--- ExportStreamListener.h
+++ ExportStreamListener.h
@@ -53,23 +53,34 @@
 	class Int16Buffer : public ExportStreamListener {
 		private:
 			volatile unsigned int data;
-			volatile bool dirty;
+			volatile unsigned char flags;
+			enum FLAGS {
+				DIRTY = (1<<0),
+				RECEIVED_DATA_BEFORE = (1<<2)
+			};
 		public:
-			Int16Buffer(unsigned int address) : ExportStreamListener(address, address) {
+			Int16Buffer(unsigned int address) : ExportStreamListener(address, address), flags(0) {

 			}
 			virtual void onDcsBiosWrite(unsigned int address, unsigned int data) {
-				if (this->data != data) {
+				if (this->flags == 0) {
+					// first update ever
 					this->data = data;
-					this->dirty = true;
+					this->flags = DIRTY | RECEIVED_DATA_BEFORE;
+				} else {
+					// regular update, only accept if data has changed
+					if (this->data != data) {
+						this->data = data;
+						this->flags = DIRTY | RECEIVED_DATA_BEFORE;
+					}
 				}
 			}
-			bool hasUpdatedData() { return dirty; }
+			bool hasUpdatedData() { return (this->flags & DIRTY); }
 			unsigned int getData() {
 				uint16_t ret;
 				noInterrupts();
 				ret = data;
-				dirty = false;
+				flags &= ~(DIRTY); // clear dirty bit
 				interrupts();

 				return ret;


Initialize swappedinput to silence the compiler warning about uninitialized variables.

--- Modules/_iconv_codec.c
+++ Modules/_iconv_codec.c
@@ -92,7 +92,7 @@
     size_t               inplen, inplen_total, outlen, outlen_total, estep;
     PyObject            *outputobj = NULL, *errorcb = NULL,
                         *exceptionobj = NULL;
-    Py_UNICODE          *swappedinput;
+    Py_UNICODE          *swappedinput = NULL;
     int                  swapi;

     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "u#|s:encode",


Remove some unused variables from gethostbyaddr_ex and gethostbyaddr, discovered by Marc Lemburg.

--- Modules/socketmodule.c
+++ Modules/socketmodule.c
@@ -1402,7 +1402,6 @@
 	char *name;
 	struct hostent *h;
 	struct sockaddr_in addr;
-	PyObject *addr_list = (PyObject *)NULL;
 #ifdef HAVE_GETHOSTBYNAME_R
 	struct hostent hp_allocated;
 	char buf[16384];
@@ -1445,9 +1444,6 @@
         struct sockaddr_in addr;
 	char *ip_num;
 	struct hostent *h;
-	PyObject *rtn_tuple = (PyObject *)NULL;
-	PyObject *name_list = (PyObject *)NULL;
-	PyObject *addr_list = (PyObject *)NULL;
 #ifdef HAVE_GETHOSTBYNAME_R
 	struct hostent hp_allocated;
 	char buf[16384];


r23: - Remove support for multiple mappings in vulpes: it's broken, unused,
and unnecessary.  (Fauxide doesn't support multiple instances, and for its
replacements, we should be using a separate vulpes instance for each virtual
disk.)

- For those command-line options we should only be given once, make sure
we actually only get them once.

- Reformat usage message to improve readability.

- Add --help command-line option.

--- vulpes/vulpes.c
+++ vulpes/vulpes.c
@@ -51,8 +51,6 @@
 #define VULPES_DEBUG(fmt, args...)     ;
 #endif

-#define MAX_NUM_MAPPINGS               16
-
 /* GLOBALS */

 static int exit_main_loop = 0;
@@ -65,8 +63,7 @@

 const char *vulpes_version = "0.60";

-static int num_mappings = 0;
-static vulpes_mapping_t mapping[MAX_NUM_MAPPINGS];
+static vulpes_mapping_t mapping;
 extern char *optarg;
 extern int optind, opterr, optopt;

@@ -97,9 +94,9 @@

 /* FUNCTIONS */
-__inline int valid_stats(vulpes_mapping_t * map_ptr)
-{
-  return (map_ptr->stats != NULL);
+__inline int valid_stats(void)
+{
+  return (mapping.stats != NULL);
 }

 void vulpes_signal_handler(int sig)
@@ -113,32 +110,29 @@
   return;
 }

-int vulpes_register(vulpes_id_t id)
+int vulpes_register(void)
 {
   int i;
   int result = 0;
   vulpes_regblk_t regblk;
   vulpes_cmdblk_t cmdblk;
-  vulpes_mapping_t *map_ptr;
-
-  map_ptr = &mapping[id];
-
-  map_ptr->reg.vulpes_id = id;
-  map_ptr->reg.pid = getpid();
-  map_ptr->reg.volsize = (*map_ptr->volsize_func) (map_ptr);
-
-  regblk.reg = mapping[id].reg;
+
+  mapping.reg.vulpes_id = 0;
+  mapping.reg.pid = getpid();
+  mapping.reg.volsize = (*mapping.volsize_func) (&mapping);
+
+  regblk.reg = mapping.reg;

   if (VULPES_REGBLK_SECT_PER_BUF % VULPES_CMDBLK_SECT_PER_BUF == 0) {
     int num_cmds =
       VULPES_REGBLK_SECT_PER_BUF / VULPES_CMDBLK_SECT_PER_BUF;
     for (i = 0; i < num_cmds; i++) {
       /* Create a dummy cmdblk to use the mapping.read function */
-      cmdblk.head.vulpes_id = id;
+      cmdblk.head.vulpes_id = 0;
       cmdblk.head.cmd = VULPES_CMD_READ;
       cmdblk.head.start_sect = 0;
       cmdblk.head.num_sect = VULPES_CMDBLK_SECT_PER_BUF;
-      result = (*map_ptr->read_func) (map_ptr, &cmdblk);
+      result = (*mapping.read_func) (&mapping, &cmdblk);
       if (result == -1)
 	{
 	  vulpes_log(LOG_ERRORS,"VULPES_REGISTER","failed in vulpes register: read_func failed");
@@ -151,7 +145,7 @@
     }

     result =
-      ioctl(map_ptr->vulpes_device, FAUXIDE_IOCTL_REGBLK_REGISTER,
+      ioctl(mapping.vulpes_device, FAUXIDE_IOCTL_REGBLK_REGISTER,
 	    &regblk);
   } else {
     vulpes_log(LOG_ERRORS,"VULPES_REGISTER","bad buffer sizes");
@@ -162,13 +156,13 @@
   return result;
 }

-int vulpes_unregister(vulpes_id_t id)
+int vulpes_unregister(void)
 {
   int result = 0;

   result =
-    ioctl(mapping[id].vulpes_device, FAUXIDE_IOCTL_REGBLK_UNREGISTER,
-	  &mapping[id].reg);
+    ioctl(mapping.vulpes_device, FAUXIDE_IOCTL_REGBLK_UNREGISTER,
+	  &mapping.reg);

   return result;
 }
@@ -194,21 +188,14 @@
 int cmdblk_ok(const vulpes_cmd_head_t * head)
 {
   int result = 1;
-  vulpes_id_t id;
-
-  id = head->vulpes_id;
-
-  /* Check the vulpes_id */
-  if (id >= num_mappings) {
-    result = 0;
-    return result;
-  }
+
+  /* vulpes_id is now ignored */

   /* Check command parameters */
   switch (head->cmd) {
   case VULPES_CMD_READ:
   case VULPES_CMD_WRITE:
-    if (head->start_sect + head->num_sect > mapping[id].reg.volsize)
+    if (head->start_sect + head->num_sect > mapping.reg.volsize)
       result = 0;
     break;
   default:
@@ -276,45 +263,41 @@
   return result;
 }

-void initialize_null_mapping(vulpes_id_t id)
-{
-  vulpes_mapping_t *map_ptr;
-
-  map_ptr = &(mapping[id]);
-
-  map_ptr->trxfer = LOCAL_TRANSPORT;
-  map_ptr->type = NO_MAPPING;
-
-  map_ptr->proxy_name = NULL;
-  map_ptr->proxy_port = 80;
-  map_ptr->outgoing_interface = NULL;
-
-  map_ptr->device_name = NULL;
-  map_ptr->file_name = NULL;
-  map_ptr->cache_name = NULL;
-
-  map_ptr->keyring_name = NULL;
-
-  map_ptr->vulpes_device = -1;
-
-  map_ptr->reg.vulpes_id = -1;
-  map_ptr->reg.pid = -1;
-  map_ptr->reg.volsize = 0;
-
-  map_ptr->open_func = NULL;
-  map_ptr->volsize_func = NULL;
-  map_ptr->read_func = NULL;
-  map_ptr->write_func = NULL;
-  map_ptr->close_func = NULL;
-
-  map_ptr->verbose = 0;
-
-  map_ptr->lka_svc = NULL;
-  map_ptr->special = NULL;
-  map_ptr->stats = NULL;
-}
-
-int initialize_vulpes_stats(vulpes_mapping_t * map_ptr)
+void initialize_null_mapping(void)
+{
+  mapping.trxfer = LOCAL_TRANSPORT;
+  mapping.type = NO_MAPPING;
+
+  mapping.proxy_name = NULL;
+  mapping.proxy_port = 80;
+  mapping.outgoing_interface = NULL;
+
+  mapping.device_name = NULL;
+  mapping.file_name = NULL;
+  mapping.cache_name = NULL;
+
+  mapping.keyring_name = NULL;
+
+  mapping.vulpes_device = -1;
+
+  mapping.reg.vulpes_id = -1;
+  mapping.reg.pid = -1;
+  mapping.reg.volsize = 0;
+
+  mapping.open_func = NULL;
+  mapping.volsize_func = NULL;
+  mapping.read_func = NULL;
+  mapping.write_func = NULL;
+  mapping.close_func = NULL;
+
+  mapping.verbose = 0;
+
+  mapping.lka_svc = NULL;
+  mapping.special = NULL;
+  mapping.stats = NULL;
+}
+
+int initialize_vulpes_stats(void)
 {
   vulpes_stats_t *ptr;

@@ -329,7 +312,7 @@
   ptr->close = NULL;
   ptr->special = NULL;

-  map_ptr->stats = ptr;
+  mapping.stats = ptr;

   return 0;
 }
@@ -342,15 +325,25 @@
 void usage (const char *progname)
 {
   version();
-  printf("usage: %s [--pid] --map <maptype> <device_name> <local_cache_name> --master <transfertype> <master_disk_location/url> --keyring <keyring_file> [--log <logfile> <info_str> <filemask> <stdoutmask>] [--debug] [--lka <lkatype:lkadir>] [--proxy proxy_server port-number] \n", progname);
-  printf("\tIf debug is chosen, then log messages for chosen loglevel(s) will be written out to the logfile without any buffering\n");
-  printf ("\tmaptype has to be lev1\n");
-  printf ("\ttransfertype is one of: local http\n");
-  printf ("\tlkatype must be hfs-sha-1\n");
-  printf ("\tproxy_server is the ip address or the hostname of the proxy\n");
-  printf("usage: %s --version                 Print version information and exit.\n", progname);
-  printf("usage: %s --rescue <device_name>    Attempt to rescue a hung driver and exit.\n", progname);
-  /*  printf ("\tinterface is the outgoing network interface/ip-address/hostname to use to connect to proxy on this machine\n");*/
+  printf("Usage: %s <options>\n", progname);
+  printf("Options:\n");
+  printf("\t--map <maptype> <device_name> <local_cache_name>\n");
+    printf("\t\tmaptype has to be lev1\n");
+  printf("\t--master <transfertype> <master_disk_location/url>\n");
+    printf("\t\ttransfertype is one of: local http\n");
+  printf("\t--keyring <keyring_file>\n");
+  printf("\t[--log <logfile> <info_str> <filemask> <stdoutmask>]\n");
+  printf("\t[--debug]\n");
+    printf("\t\tIf debug is chosen, then log messages for chosen loglevel(s)\n");
+    printf("\t\twill be written out to the logfile without any buffering\n");
+  printf("\t[--pid]\n");
+  printf("\t[--lka <lkatype:lkadir>]\n");
+    printf("\t\tlkatype must be hfs-sha-1\n");
+  printf("\t[--proxy proxy_server port-number]\n");
+    printf("\t\tproxy_server is the ip address or the hostname of the proxy\n");
+  printf("Usage: %s --help                  Print usage summary and exit.\n", progname);
+  printf("Usage: %s --version               Print version information and exit.\n", progname);
+  printf("Usage: %s --rescue <device_name>  Rescue a hung Fauxide driver and exit.\n", progname);
   exit(0);
 }

@@ -358,8 +351,6 @@
 {
   void *old_sig_handler;
   vulpes_cmdblk_t cmdblk;
-  vulpes_id_t id;
-  unsigned i;
   pid_t pid;
   const char* logName;
   const char* log_infostr;
@@ -371,14 +362,14 @@
   int masterDone=0;
   int keyDone=0;
   int logDone=0;
+  int mapDone=0;
+  int proxyDone=0;

   /* Initialize the fidsvc */
   fidsvc_init();

-  /* Initialize the mapping array */
-  for (i = 0; i <= num_mappings; i++) {
-    initialize_null_mapping(i);
-  }
+  /* Initialize the mapping structure */
+  initialize_null_mapping();

   /* parse command line */
   if (argc < 2) {
@@ -409,12 +400,12 @@
 	/*{"interface", no_argument, 0, 'j'},
 	  {"noencryption", no_argument, 0, 'k'},*/
 	{"lka", no_argument, 0, 'l'},
+	{"help", no_argument, 0, 'm'},
 	{0,0,0,0}
       };

     int option_index=0;
     int opt_retVal;
-    vulpes_mapping_t *current_mapping=&(mapping[0]);

     opt_retVal=getopt_long(argc,argv, "", vulpes_cmdline_options,
 			   &option_index);
@@ -423,11 +414,13 @@
       break;
     switch(opt_retVal) {
     case 'a':
+      /* version */
       requiredArgs+=1;
       version();
       exit(0);
       break;
     case 'b':
+      /* rescue */
       requiredArgs+=2;
       if (optind+0 >= argc) {
 	printf("ERROR: device_name required for RESCUE.\n");
@@ -442,58 +435,71 @@
       exit(0);
       break;
     case 'c':
+      /* pid */
       requiredArgs+=1;
       printf("VULPES: pid = %ld\n", (long) pid);
       break;
-    case 'd':
+    case 'd':
+      /* map */
       {
 	mapping_type_t type;

+	if (mapDone) {
+	  printf("ERROR: --map may only be specified once.\n");
+	  usage(argv[0]);
+	}
 	requiredArgs+=4;
 	if (optind+2 >= argc) {
 	  printf("ERROR: failed to parse mapping.\n");
 	  usage(argv[0]);
 	}
-
-	/* each time we see a new --map (except the first), start a new mapping */
-	current_mapping=&(mapping[num_mappings]);
-	++num_mappings;

 	type = char_to_mapping_type(argv[optind++]);
 	if(type == NO_MAPPING) {
 	  printf("ERROR: unknown mapping type (%s).\n", argv[optind-1]);
 	  usage(argv[0]);
 	}
-	current_mapping->type = type;
-	current_mapping->device_name=argv[optind++];
-	current_mapping->cache_name=argv[optind++];
+	mapping.type = type;
+	mapping.device_name=argv[optind++];
+	mapping.cache_name=argv[optind++];
+	mapDone=1;
       }
       break;
     case 'e':
+      /* master */
+      if (masterDone) {
+	printf("ERROR: --master may only be specified once.\n");
+	usage(argv[0]);
+      }
       requiredArgs+=3;
       if (optind+1 >= argc) {
 	printf("ERROR: failed to parse transport.\n");
 	usage(argv[0]);
       }
       if (strcmp("http",argv[optind])==0)
-	current_mapping->trxfer=HTTP_TRANSPORT;
+	mapping.trxfer=HTTP_TRANSPORT;
       else if (strcmp("local",argv[optind])==0)
-	current_mapping->trxfer=LOCAL_TRANSPORT;
+	mapping.trxfer=LOCAL_TRANSPORT;
       else {
 	printf("ERROR: unknown transport type.\n");
 	usage(argv[0]);
       }
       optind++;
-      current_mapping->file_name=argv[optind++];
+      mapping.file_name=argv[optind++];
       masterDone=1;
       break;
     case 'f':
+      /* keyring */
+      if (keyDone) {
+	printf("ERROR: --keyring may only be specified once.\n");
+	usage(argv[0]);
+      }
       requiredArgs+=2;
       if (optind+0 >= argc) {
 	printf("ERROR: failed to parse keyring name.\n");
 	usage(argv[0]);
       }
-      current_mapping->keyring_name=argv[optind++];
+      mapping.keyring_name=argv[optind++];
       keyDone=1;
       break;
       /*case 'g': {
@@ -532,6 +538,11 @@
 	};
 	break;*/
     case 'h':
+      /* log */
+      if (logDone) {
+	printf("ERROR: --log may only be specified once.\n");
+	usage(argv[0]);
+      }
       requiredArgs+=5;
       if (optind+2 >= argc) {
 	printf("ERROR: failed to parse logging.\n");
@@ -545,9 +556,15 @@
       logDone=1;
       break;
     case 'i':
+      /* proxy */
       {
 	char *error_buffer;
 	long tmp_num;
+
+	if (proxyDone) {
+	  printf("ERROR: --proxy may only be specified once.\n");
+	  usage(argv[0]);
+	}
 	requiredArgs+=3;
 	error_buffer=(char*)malloc(64);
 	error_buffer[0]=0;
@@ -555,40 +572,45 @@
 	  printf("ERROR: failed to parse proxy description.\n");
 	  usage(argv[0]);
 	}
-	current_mapping->proxy_name=argv[optind++];
+	mapping.proxy_name=argv[optind++];
 	tmp_num=strtol(argv[optind++], &error_buffer,10);
 	if (strlen(error_buffer)!=0)
 	  {
 	    printf("bad port\n");
 	    usage(argv[0]);
 	  }
-	current_mapping->proxy_port=tmp_num;
+	mapping.proxy_port=tmp_num;
 	free(error_buffer);
+	proxyDone=1;
       }
       break;
       /*			case 'j':
 				requiredArgs+=2;
 				if (optind+0 >= argc)
 				usage(argv[0]);
-				current_mapping->outgoing_interface=argv[optind++];
+				mapping.outgoing_interface=argv[optind++];
 				break;
 				case 'k':
 				requiredArgs+=1;
       */
     case 'l':
+      /* lka */
       requiredArgs+=2;
       if (optind+0 >= argc) {
 	printf("ERROR: failed to parse lka option.\n");
 	usage(argv[0]);
       }
-      if(current_mapping->lka_svc == NULL)
-	if((current_mapping->lka_svc = vulpes_lka_open()) == NULL)
+      if(mapping.lka_svc == NULL)
+	if((mapping.lka_svc = vulpes_lka_open()) == NULL)
 	  printf("WARNING: unable to open lka service.\n");
-      if(current_mapping->lka_svc != NULL)
-	if(vulpes_lka_add(current_mapping->lka_svc, argv[optind]) != VULPES_LKA_RETURN_SUCCESS)
+      if(mapping.lka_svc != NULL)
+	if(vulpes_lka_add(mapping.lka_svc, argv[optind]) != VULPES_LKA_RETURN_SUCCESS)
 	  printf("WARNING: unable to add lka database %s.\n", argv[optind]);
       optind++;
       break;
+    case 'm':
+      /* help */
+      usage(argv[0]);
     default:
       printf("ERROR: unknown command line option.\n");
       usage(argv[0]);
@@ -608,8 +630,8 @@
     printf("--master parameter missing\n");
     usage(argv[0]);
   }
-  if (num_mappings < 1) {
-    printf("--map paramater missing\n");
+  if (mapDone==0) {
+    printf("--map parameter missing\n");
     usage(argv[0]);
   }

@@ -643,98 +665,94 @@
   }

-  /* Establish the mappings */
-  VULPES_DEBUG("Establishing mappings...\n");
-  for (i = 0; i < num_mappings; i++) {
-    mapping_type_t type=mapping[i].type ;
-    /* Initialize the mapping */
-    switch (type) {
-    case SIMPLE_FILE_MAPPING:
-    case SIMPLE_DISK_MAPPING:
+  VULPES_DEBUG("Establishing mapping...\n");
+  /* Initialize the mapping */
+  switch (mapping.type) {
+  case SIMPLE_FILE_MAPPING:
+  case SIMPLE_DISK_MAPPING:
 #ifdef VULPES_SIMPLE_DEFINED
-      if (initialize_simple_mapping(&mapping[i])) {
-	vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: unable to initialize simple mapping %u",i);
-	goto vulpes_exit;
-      }
+    if (initialize_simple_mapping(&mapping)) {
+      vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: unable to initialize simple mapping");
+      goto vulpes_exit;
+    }
 #else
-      vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: simple mapping not supported in this version.");
+    vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: simple mapping not supported in this version.");
+    goto vulpes_exit;
+#endif
+    break;
+  case LEV1_MAPPING:
+  case LEV1V_MAPPING:
+  case ZLEV1_MAPPING:
+  case ZLEV1V_MAPPING:	{
+    if (initialize_lev1_mapping(&mapping)) {
+      vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to initialize lev1 mapping");
       goto vulpes_exit;
-#endif
-      break;
-    case LEV1_MAPPING:
-    case LEV1V_MAPPING:
-    case ZLEV1_MAPPING:
-    case ZLEV1V_MAPPING:	{
-      if (initialize_lev1_mapping(&mapping[i])) {
-	vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to initialize lev1 mapping");
-	goto vulpes_exit;
-      }
-    }
-      break;
-    case NO_MAPPING:
-    default:
-      vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: unknown mapping type %u",i);
+    }
+  }
+    break;
+  case NO_MAPPING:
+  default:
+    vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: unknown mapping type");
+    goto vulpes_exit;
+  }
+
+  /* Open the device */
+  VULPES_DEBUG("\tOpening device\n");
+  mapping.vulpes_device = open(mapping.device_name, O_RDWR);
+  if (mapping.vulpes_device < 0) {
+    vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to open device %s",mapping.device_name);
+    goto vulpes_exit;
+  }
+
+  /* Open the file */
+  VULPES_DEBUG("\tOpening file %d.\n", (int) i);
+  if ((*(mapping.open_func)) (&mapping)) {
+    vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to open lev1 %s", mapping.file_name);
+    goto vulpes_exit;
+  }
+
+  /* Open the stats */
+  if (valid_stats()) {
+    VULPES_DEBUG("\tOpening stats.\n");
+    if ((*(mapping.stats->open)) (mapping.stats)) {
+      vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: unable to open stats");
       goto vulpes_exit;
     }
-
+  }
+
+  /* Register ourselves with the device */
+  VULPES_DEBUG("\tRegistering device.\n");
+  if (vulpes_register()) {
+    vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to register process with device");
+    goto vulpes_exit;
+  }
+  vulpes_log(LOG_BASIC,"VULPES_MAIN","Registered process with device");
+
+  /* Need to register twice to get 2.6 kernel module to recognize driver properly */
+  if (running_kernel26()) {
+    /* Unregister process */
+    VULPES_DEBUG("\tUnregistering device.\n");
+    if (vulpes_unregister()) {
+      vulpes_log(LOG_ERRORS,"VULPES_MAIN","failed to unregister: %s", mapping.device_name);
+    }
+    vulpes_log(LOG_BASIC,"VULPES_MAIN","un-Registered process with device");
+    /* Close device */
+    VULPES_DEBUG("\tClosing device.\n");
+    close(mapping.vulpes_device);
     /* Open the device */
-    VULPES_DEBUG("\tOpening device %d.\n", (int) i);
-    mapping[i].vulpes_device = open(mapping[i].device_name, O_RDWR);
-    if (mapping[i].vulpes_device < 0) {
-      vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to open device %s",mapping[i].device_name);
+    VULPES_DEBUG("\tOpening device.\n");
+    mapping.vulpes_device = open(mapping.device_name, O_RDWR);
+    if (mapping.vulpes_device < 0) {
+      vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to open device %s",mapping.device_name);
       goto vulpes_exit;
     }
-
-    /* Open the file */
-    VULPES_DEBUG("\tOpening file %d.\n", (int) i);
-    if ((*(mapping[i].open_func)) (&mapping[i])) {
-      vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to open lev1 %s", mapping[i].file_name);
-      goto vulpes_exit;
-    }
-
-    /* Open the stats */
-    if (valid_stats(&mapping[i])) {
-      VULPES_DEBUG("\tOpening stats %d.\n", (int) i);
-      if ((*(mapping[i].stats->open)) (mapping[i].stats)) {
-	vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: unable to open stats %u",i);
-	goto vulpes_exit;
-      }
-    }
-
     /* Register ourselves with the device */
-    VULPES_DEBUG("\tRegistering device %d.\n", (int) i);
-    if (vulpes_register(i)) {
+    VULPES_DEBUG("\tRegistering device.\n");
+    if (vulpes_register()) {
       vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to register process with device");
       goto vulpes_exit;
     }
     vulpes_log(LOG_BASIC,"VULPES_MAIN","Registered process with device");
-
-    /* Need to register twice to get 2.6 kernel module to recognize driver properly */
-    if (running_kernel26()) {
-      /* Unregister process */
-      VULPES_DEBUG("\tUnregistering device %d.\n", (int) i);
-      if (vulpes_unregister(i)) {
-	vulpes_log(LOG_ERRORS,"VULPES_MAIN","failed to unregister: %s", mapping[i].device_name);
-      }
-      vulpes_log(LOG_BASIC,"VULPES_MAIN","un-Registered process with device");
-      /* Close device */
-      VULPES_DEBUG("\tClosing device %d.\n", (int) i);
-      close(mapping[i].vulpes_device);
-      /* Open the device */
-      VULPES_DEBUG("\tOpening device %d.\n", (int) i);
-      mapping[i].vulpes_device = open(mapping[i].device_name, O_RDWR);
-      if (mapping[i].vulpes_device < 0) {
-	vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to open device %s",mapping[i].device_name);
-	goto vulpes_exit;
-      }
-      /* Register ourselves with the device */
-      VULPES_DEBUG("\tRegistering device %d.\n", (int) i);
-      if (vulpes_register(i)) {
-	vulpes_log(LOG_ERRORS,"VULPES_MAIN","unable to register process with device");
-	goto vulpes_exit;
-      }
-      vulpes_log(LOG_BASIC,"VULPES_MAIN","Registered process with device");
-    }
   }

   /* Initialize cmdblk */
@@ -743,23 +761,18 @@
   cmdblk.head.fauxide_id=NULL;

   /* Enter processing loop */
-  id = 0;
   do {
-    vulpes_mapping_t *map_ptr;
     int result = 0;

-    /* Execute ioctl -- use last id */
-    ioctl(mapping[id].vulpes_device, FAUXIDE_IOCTL_CMDBLK, &cmdblk);
-
-    id = cmdblk.head.vulpes_id;
-    map_ptr = &mapping[id];
+    /* Execute ioctl */
+    ioctl(mapping.vulpes_device, FAUXIDE_IOCTL_CMDBLK, &cmdblk);

     /* Process cmd */
     switch (cmdblk.head.cmd) {
     case VULPES_CMD_READ:
       vulpes_log(LOG_FAUXIDE_REQ,"READ_IN","%llu:%lu:%lu",request_counter,cmdblk.head.start_sect,cmdblk.head.num_sect);
       if (cmdblk_ok(&(cmdblk.head))) {
-	result = (*map_ptr->read_func) (map_ptr, &cmdblk);
+	result = (*mapping.read_func) (&mapping, &cmdblk);
       } else {
 	vulpes_log(LOG_ERRORS,"VULPES_MAIN","%llu:%lu:%lu: bad cmdblk",request_counter,cmdblk.head.start_sect,cmdblk.head.num_sect);
 	result = -1;
@@ -767,8 +780,8 @@
       vulpes_log(LOG_FAUXIDE_REQ,"READ_OUT","%llu:%lu:%lu",request_counter,cmdblk.head.start_sect,cmdblk.head.num_sect);
       if (result == 0) {
 	tally_sector_accesses(0, cmdblk.head.num_sect);
-	if (valid_stats(map_ptr)) {
-	  if ((*map_ptr->stats->record_read) (map_ptr->stats,&cmdblk.head)) {
+	if (valid_stats()) {
+	  if ((*mapping.stats->record_read) (mapping.stats,&cmdblk.head)) {
 	    vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: issuing logstats record_read()");
 	  }
 	}
@@ -782,15 +795,15 @@
     case VULPES_CMD_WRITE:
       vulpes_log(LOG_FAUXIDE_REQ,"WRITE_IN","%llu:%lu:%lu",request_counter,cmdblk.head.start_sect,cmdblk.head.num_sect);
       if (cmdblk_ok(&(cmdblk.head))) {
-	result = (*map_ptr->write_func) (map_ptr, &cmdblk);
+	result = (*mapping.write_func) (&mapping, &cmdblk);
       } else {
 	result = -1;
       }
       vulpes_log(LOG_FAUXIDE_REQ,"WRITE_DONE","%llu:%lu:%lu",request_counter,cmdblk.head.start_sect,cmdblk.head.num_sect);
       if (result == 0) {
 	tally_sector_accesses(1, cmdblk.head.num_sect);
-	if (valid_stats(map_ptr)) {
-	  if ((*map_ptr->stats->record_write) (map_ptr->stats,&cmdblk.head)) {
+	if (valid_stats()) {
+	  if ((*mapping.stats->record_write) (mapping.stats,&cmdblk.head)) {
 	    vulpes_log(LOG_ERRORS,"VULPES_MAIN","ERROR: issuing logstats record_write()");
 	  }
 	}
@@ -833,38 +846,36 @@

   /* Unmap */
   vulpes_log(LOG_BASIC,"VULPES_MAIN", "Beginning vulpes shutdown sequence");
-  for (i = 0; i < num_mappings; i++) {
-    /* Unregister process */
-    VULPES_DEBUG("\tUnregistering device %d.\n", (int) i);
-    if (vulpes_unregister(i)) {
-      vulpes_log(LOG_ERRORS,"VULPES_MAIN","failed to unregister %s", mapping[i].device_name);
-    }
-    vulpes_log(LOG_BASIC,"VULPES_MAIN","un-Registered process with device");
-
-    /* Close device */
-    VULPES_DEBUG("\tClosing device %d.\n", (int) i);
-    close(mapping[i].vulpes_device);
-
-    /* Close stats */
-    VULPES_DEBUG("\tClosing stats %d.\n", (int) i);
-    if (valid_stats(&mapping[i])) {
-      (*mapping[i].stats->close) (mapping[i].stats);
-      free(mapping[i].stats);
-      mapping[i].stats = NULL;
-    }
-
-    /* Close file */
-    VULPES_DEBUG("\tClosing map %d.\n", (int) i);
-    if ((*mapping[i].close_func) (&mapping[i]) == -1) {
-	vulpes_log(LOG_ERRORS,"VULPES_MAIN","close function failed");
-	exit(1);
-      }
-
-    /* Close the LKA service */
-    if(mapping[i].lka_svc != NULL)
-      if(vulpes_lka_close(mapping[i].lka_svc) != VULPES_LKA_RETURN_SUCCESS)
-	vulpes_log(LOG_ERRORS,"VULPES_MAIN","failure during lka_close().");
-  }
+  /* Unregister process */
+  VULPES_DEBUG("\tUnregistering device.\n");
+  if (vulpes_unregister()) {
+    vulpes_log(LOG_ERRORS,"VULPES_MAIN","failed to unregister %s", mapping.device_name);
+  }
+  vulpes_log(LOG_BASIC,"VULPES_MAIN","un-Registered process with device");
+
+  /* Close device */
+  VULPES_DEBUG("\tClosing device.\n");
+  close(mapping.vulpes_device);
+
+  /* Close stats */
+  VULPES_DEBUG("\tClosing stats.\n",);
+  if (valid_stats()) {
+    (*mapping.stats->close) (mapping.stats);
+    free(mapping.stats);
+    mapping.stats = NULL;
+  }
+
+  /* Close file */
+  VULPES_DEBUG("\tClosing map.\n");
+  if ((*mapping.close_func) (&mapping) == -1) {
+      vulpes_log(LOG_ERRORS,"VULPES_MAIN","close function failed");
+      exit(1);
+    }
+
+  /* Close the LKA service */
+  if(mapping.lka_svc != NULL)
+    if(vulpes_lka_close(mapping.lka_svc) != VULPES_LKA_RETURN_SUCCESS)
+      vulpes_log(LOG_ERRORS,"VULPES_MAIN","failure during lka_close().");

   /* Close the fidsvc */
   fidsvc_close();
@@ -878,7 +889,5 @@
  vulpes_exit:
   vulpes_log(LOG_BASIC,"VULPES_FINISH", "");
   vulpes_log_close();
-  exit(0);
-
   return 0;
 }


Fix a bunch of warnings reported by Skip.

To whoever who changed a bunch of (PyCFunction) casts to
(PyNoArgsFunction) in PyMethodDef initializers: don't do that.  The
cast is to shut the compiler up.  The compiler wants the function
pointer initializer to be a PyCFunction.

--- Modules/socketmodule.c
+++ Modules/socketmodule.c
@@ -1622,27 +1622,27 @@
 /* List of methods for socket objects */

 static PyMethodDef PySocketSock_methods[] = {
-	{"accept",	(PyNoArgsFunction)PySocketSock_accept, METH_NOARGS,
+	{"accept",	(PyCFunction)PySocketSock_accept, METH_NOARGS,
 			accept_doc},
 	{"bind",	(PyCFunction)PySocketSock_bind, METH_O,
 			bind_doc},
-	{"close",	(PyNoArgsFunction)PySocketSock_close, METH_NOARGS,
+	{"close",	(PyCFunction)PySocketSock_close, METH_NOARGS,
 			close_doc},
 	{"connect",	(PyCFunction)PySocketSock_connect, METH_O,
 			connect_doc},
 	{"connect_ex",	(PyCFunction)PySocketSock_connect_ex, METH_O,
 			connect_ex_doc},
 #ifndef NO_DUP
-	{"dup",		(PyNoArgsFunction)PySocketSock_dup, METH_NOARGS,
+	{"dup",		(PyCFunction)PySocketSock_dup, METH_NOARGS,
 			dup_doc},
 #endif
-	{"fileno",	(PyNoArgsFunction)PySocketSock_fileno, METH_NOARGS,
+	{"fileno",	(PyCFunction)PySocketSock_fileno, METH_NOARGS,
 			fileno_doc},
 #ifdef HAVE_GETPEERNAME
-	{"getpeername",	(PyNoArgsFunction)PySocketSock_getpeername,
+	{"getpeername",	(PyCFunction)PySocketSock_getpeername,
 	                METH_NOARGS, getpeername_doc},
 #endif
-	{"getsockname",	(PyNoArgsFunction)PySocketSock_getsockname,
+	{"getsockname",	(PyCFunction)PySocketSock_getsockname,
 	                METH_NOARGS, getsockname_doc},
 	{"getsockopt",	(PyCFunction)PySocketSock_getsockopt, METH_VARARGS,
 			getsockopt_doc},
@@ -2733,8 +2733,8 @@
 	          PySSL_SSLwrite_doc},
 	{"read", (PyCFunction)PySSL_SSLread, 1,
 	          PySSL_SSLread_doc},
-	{"server", (PyNoArgsFunction)PySSL_server, METH_NOARGS},
-	{"issuer", (PyNoArgsFunction)PySSL_issuer, METH_NOARGS},
+	{"server", (PyCFunction)PySSL_server, METH_NOARGS},
+	{"issuer", (PyCFunction)PySSL_issuer, METH_NOARGS},
 	{NULL, NULL}
 };


2013 - Concorrente : EP2 fazendo com que a bellard receba os termos pre calculados por parametro de entrada.

--- 2013/mac0438/ep2/ep2.c
+++ 2013/mac0438/ep2/ep2.c
@@ -23,6 +23,8 @@
 #include <float.h>
 #include <limits.h>

+#define MAX_TERMOS 1000
+
   /****************************************/
  /* Inicialização das variáveis globais. */
 /****************************************/
@@ -58,14 +60,36 @@
    return ptr;
 }

-long double bellard( int p) {
-	long double termo = 0,
-					buffm4,
-					buffm10,
-					buffp2;
-	long int buffN0, buffn;
-
-	/* Efetua a leitura atomicamente */
+long double bellard(
+	long int ln,
+	long int lm4,
+	long int lm10,
+	long int lp2
+) {
+	long double
+		termo = 0;
+
+	termo += -32. / (lm4+1);
+	termo += -1.  / (lm4+3);
+	termo += 256. / (lm10+1);
+	termo += -64. / (lm10+3);
+	termo += -4.  / (lm10+5);
+	termo += -4.  / (lm10+7);
+	termo += 1.   / (lm10+9);
+	termo /= lp2;
+
+	return (n % 2) ? -termo : termo;
+}
+
+void *calculaTermo( void *t) {
+	int p = *(int *) t;
+	long double termthread;
+
+	/* Enquanto a diferenca entre duas iteracoes consecutivas for maior que f
+	 * (parametro de entrada) continua.
+	 ***********************************************************************/
+
+	/*
 	sem_wait( &sem_writeread);
 	buffm10 = m10;
 	m10 *= 10;
@@ -76,31 +100,17 @@
 	buffN0 = ++N0;
 	buffn = ++n;
 	sem_post( &sem_writeread);
-	termo += -32. / (buffm4+1 + 4*(buffn-buffN0));
-	termo += -1.  / (buffm4+3 + 4*(buffn-buffN0));
-	termo += 256. / (buffm10+1 + 10*(buffn-buffN0));
-	termo += -64. / (buffm10+3 + 10*(buffn-buffN0));
-	termo += -4.  / (buffm10+5 + 10*(buffn-buffN0));
-	termo += -4.  / (buffm10+7 + 10*(buffn-buffN0));
-	termo += 1.   / (buffm10+9 + 10*(buffn-buffN0));
-	termo /= buffp2;
+
 	sem_wait( &sem_writeread);
 	(buffn % 2) ? (pi -= termo) : (pi += termo);
 	printf( "thread: %d - it: %ld\tpi=%.20Lf\n", p, buffn, pi);
 	sem_post( &sem_writeread);
-
-	return (n % 2) ? -termo : termo;
-}
-
-void *calculaTermo( void *t) {
-	int p = *(int *) t;
-	long double termthread;
-
-	/* Enquanto a diferenca entre duas iteracoes consecutivas for maior que f
-	 * (parametro de entrada) continua.
-	 ***********************************************************************/
+	*/
+
 	do {
+		/*
 		termthread = bellard( p);
+		*/
 	} while (termthread > precisao && termthread > LDBL_EPSILON);
 	return NULL;
 }
@@ -115,7 +125,8 @@
 	double d, s=0, d2;
 	long double mem;
 	pthread_t *threads = (pthread_t *) mallocX( numCPU * sizeof (pthread_t));
-printf( "\n\tcores=%d\n\n", numCPU);
+	printf( "\n\tcores=%d\n\n", numCPU);
+
 	/* Inicializando variaveis globais.
 	 *********************************/
 	param = 0;
@@ -125,23 +136,9 @@
 	m4 = 0;
 	m10 = 0;
 	p2 = 64;
-	precisao = LDBL_EPSILON; /* Posteriormente sera parametro de entrada */
-
-	/*
-	for( i=0; i<10; i++){
-		mem = bellard(i);
-		printf("%.100Lf\n", mem);
-		pi += mem;
-
-		m4 += 4;
-		m10 += 10;
-		p2 *= 1024;
-	}
-	printf("\n\n%.100Lf\n", pi);
-
-	return 0;
-	*/
-
+
+	/* Lendo os parametros de entrada.
+	 *********************************/
 	if(argc<2) {
 		printf(
 			"Modo de uso:\n"
@@ -152,7 +149,6 @@
 		);
 	}
 	else {
-
 		for(i=1; i<argc; i++) {
 			if( strcmp(argv[i], "DEBUG")==0 )
 				param = 1;
@@ -176,33 +172,26 @@
 	for (t = 0; t < numCPU; t++)
 		pthread_join( threads[t], NULL);
 	*/
-	sem_init( &sem_writeread, 0, 1);
-	for (t = 0; t < numCPU; ++t)
-		pthread_create( &threads[t], NULL, calculaTermo, (void *) &t);
-	for (t = 0; t < numCPU; ++t)
-		pthread_join( threads[t], NULL);
-	sem_destroy( &sem_writeread);
-/*
+
 	switch(param){
 		case 1:
-			/* DEBUG
+			/* DEBUG */
 			break;
 		case 2:
-			/* SEQUENCIAL
+			/* SEQUENCIAL */
 			termos = (long double*) mallocX(sizeof(long double));
 			n = 0;
 			do{
-				termos[0] = bellard(n);
-				pi += termos[0];
-				printf("%.20Lf\t%.20Lf\n", pi, termos[0]);
+				*termos = bellard( n, m4, m10, p2 );
+				pi += *termos;
+				printf("%.20Lf\t%.20Lf\n", pi, *termos);
 				n++;
-				N0++;
 				m4 += 4;
 				m10 += 10;
 				p2 *= 1024;

 				if(n==10) break;
-			} while( fabs(termos[0])>precisao );
+			} while( fabs(*termos)>precisao );

 			printf(
 				"\nOs resultados obtidos de maneira sequencial foram:\n"
@@ -211,9 +200,17 @@
 			);
 			break;
 		default:
-			/* NORMAL
+			/* NORMAL */
+			termos = (long double*) mallocX( MAX_TERMOS*sizeof(long double) );
+
+			sem_init( &sem_writeread, 0, 1);
+			for (t = 0; t < numCPU; ++t)
+				pthread_create( &threads[t], NULL, calculaTermo, (void *) &t);
+			for (t = 0; t < numCPU; ++t)
+				pthread_join( threads[t], NULL);
+			sem_destroy( &sem_writeread);
 			break;
-	}*/
+	}

 	return 0;
 }


patch 1754489 by vlahan: improve portability of address length calculation for AF_UNIX sockets

--- Modules/socketmodule.c
+++ Modules/socketmodule.c
@@ -1001,7 +1001,7 @@
 		struct sockaddr_un *a = (struct sockaddr_un *) addr;
 #ifdef linux
 		if (a->sun_path[0] == 0) {  /* Linux abstract namespace */
-			addrlen -= (sizeof(*a) - sizeof(a->sun_path));
+			addrlen -= offsetof(struct sockaddr_un, sun_path);
 			return PyString_FromStringAndSize(a->sun_path,
 							  addrlen);
 		}
@@ -1207,7 +1207,7 @@
 #if defined(PYOS_OS2)
 		*len_ret = sizeof(*addr);
 #else
-		*len_ret = len + sizeof(*addr) - sizeof(addr->sun_path);
+		*len_ret = len + offsetof(struct sockaddr_un, sun_path);
 #endif
 		return 1;
 	}


Added w.setwincursor(), selection, and new cut buffer interface.

--- Modules/stdwinmodule.c
+++ Modules/stdwinmodule.c
@@ -1157,6 +1157,40 @@
 		newtextobject(self, a[0], a[1], a[2], a[3]);
 }

+static object *
+window_setselection(self, args)
+	windowobject *self;
+	object *args;
+{
+	int sel;
+	object *str;
+	int ok;
+	if (!getintstrarg(args, &sel, &str))
+		return NULL;
+	ok = wsetselection(self->w_win, sel,
+		getstringvalue(str), (int)getstringsize(str));
+	return newintobject(ok);
+}
+
+static object *
+window_setwincursor(self, args)
+	windowobject *self;
+	object *args;
+{
+	object *str;
+	CURSOR *c;
+	if (!getstrarg(args, &str))
+		return NULL;
+	c = wfetchcursor(getstringvalue(str));
+	if (c == NULL) {
+		err_setstr(RuntimeError, "no such cursor");
+		return NULL;
+	}
+	wsetwincursor(self->w_win, c);
+	INCREF(None);
+	return None;
+}
+
 static struct methodlist window_methods[] = {
 	{"begindrawing",window_begindrawing},
 	{"change",	window_change},
@@ -1166,8 +1200,10 @@
 	{"getwinsize",	window_getwinsize},
 	{"menucreate",	window_menucreate},
 	{"scroll",	window_scroll},
+	{"setwincursor",window_setwincursor},
 	{"setdocsize",	window_setdocsize},
 	{"setorigin",	window_setorigin},
+	{"setselection",window_setselection},
 	{"settimer",	window_settimer},
 	{"settitle",	window_settitle},
 	{"show",	window_show},
@@ -1332,6 +1368,9 @@
 			w = None;
 		w = makemenu(w, e.u.m.item);
 		break;
+	case WE_LOST_SEL:
+		w = newintobject((long)e.u.sel);
+		break;
 	default:
 		w = None;
 		INCREF(w);
@@ -1470,10 +1509,18 @@
 	object *self;
 	object *args;
 {
+	int i;
 	object *str;
-	if (!getstrarg(args, &str))
-		return NULL;
-	wsetcutbuffer(0, getstringvalue(str), getstringsize(str));
+	/* Compatibility hack: setcutbuffer(str) === setcutbuffer(0, str) */
+	if (args != NULL && !is_tupleobject(args)) {
+		if (!getstrarg(args, &str))
+			return NULL;
+	}
+	else {
+		if (!getintstrarg(args, &i, &str))
+			return NULL;
+	}
+	wsetcutbuffer(i, getstringvalue(str), getstringsize(str));
 	INCREF(None);
 	return None;
 }
@@ -1483,16 +1530,64 @@
 	object *self;
 	object *args;
 {
+	int i;
 	char *str;
 	int len;
-	if (!getnoarg(args))
-		return NULL;
-	str = wgetcutbuffer(0, &len);
+	/* Compatibility hack: getcutbuffer() === getcutbuffer(0) */
+	if (args == NULL)
+		i = 0;
+	else if (!getintarg(args, &i))
+		return NULL;
+	str = wgetcutbuffer(i, &len);
 	if (str == NULL) {
 		str = "";
 		len = 0;
 	}
 	return newsizedstringobject(str, len);
+}
+
+static object *
+stdwin_rotatecutbuffers(self, args)
+	object *self;
+	object *args;
+{
+	int i;
+	if (!getintarg(args, &i))
+		return NULL;
+	wrotatecutbuffers(i);
+	INCREF(None);
+	return None;
+}
+
+static object *
+stdwin_getselection(self, args)
+	object *self;
+	object *args;
+{
+	int sel;
+	char *data;
+	int len;
+	if (!getintarg(args, &sel))
+		return NULL;
+	data = wgetselection(sel, &len);
+	if (data == NULL) {
+		data = "";
+		len = 0;
+	}
+	return newsizedstringobject(data, len);
+}
+
+static object *
+stdwin_resetselection(self, args)
+	object *self;
+	object *args;
+{
+	int sel;
+	if (!getintarg(args, &sel))
+		return NULL;
+	wresetselection(sel);
+	INCREF(None);
+	return None;
 }

 static struct methodlist stdwin_methods[] = {
@@ -1500,11 +1595,14 @@
 	{"askstr",		stdwin_askstr},
 	{"askync",		stdwin_askync},
 	{"fleep",		stdwin_fleep},
+	{"getselection",	stdwin_getselection},
 	{"getcutbuffer",	stdwin_getcutbuffer},
 	{"getevent",		stdwin_getevent},
 	{"menucreate",		stdwin_menucreate},
 	{"message",		stdwin_message},
 	{"open",		stdwin_open},
+	{"resetselection",	stdwin_resetselection},
+	{"rotatecutbuffers",	stdwin_rotatecutbuffers},
 	{"setcutbuffer",	stdwin_setcutbuffer},
 	{"setdefwinpos",	stdwin_setdefwinpos},
 	{"setdefwinsize",	stdwin_setdefwinsize},


Don't perform the trimdomain() functionality twice, trimdomain() now works as expected.

--- usr.bin/login/login.c
+++ usr.bin/login/login.c
@@ -42,7 +42,7 @@
 static char sccsid[] = "@(#)login.c	8.4 (Berkeley) 4/2/94";
 #endif
 static const char rcsid[] =
-	"$Id: login.c,v 1.44 1999/01/03 23:39:33 eivind Exp $";
+	"$Id: login.c,v 1.45 1999/01/19 22:59:37 abial Exp $";
 #endif /* not lint */

 /*
@@ -138,10 +138,9 @@
 	int changepass;
 	time_t warntime;
 	uid_t uid, euid;
-	char *domain, *p, *ttyn;
+	char *p, *ttyn;
 	char tbuf[MAXPATHLEN + 2];
 	char tname[sizeof(_PATH_TTY) + 10];
-	char localhost[MAXHOSTNAMELEN];
 	char *shell = NULL;
 	login_cap_t *lc = NULL;

@@ -167,12 +166,7 @@
 	 *    host to login so that it may be placed in utmp and wtmp
 	 */
 	*full_hostname = '\0';
-	domain = NULL;
 	term = NULL;
-	if (gethostname(localhost, sizeof(localhost)) < 0)
-		syslog(LOG_ERR, "couldn't get local hostname: %m");
-	else
-		domain = strchr(localhost, '.');

 	fflag = hflag = pflag = 0;
 	uid = getuid();
@@ -187,11 +181,8 @@
 				errx(1, "-h option: %s", strerror(EPERM));
 			hflag = 1;
 			strncpy(full_hostname, optarg, sizeof(full_hostname)-1);
-			if (domain && (p = strchr(optarg, '.')) &&
-			    strcasecmp(p, domain) == 0)
-				*p = 0;
-
-			trimdomain(optarg, UT_HOSTSIZE );
+
+			trimdomain(optarg, UT_HOSTSIZE);

 			if (strlen(optarg) > UT_HOSTSIZE) {
 				struct hostent *hp = gethostbyname(optarg);


Avoid signed overflow in error handling code.

Reviewed by:	cperciva, bjk

--- usr.bin/split/split.c
+++ usr.bin/split/split.c
@@ -379,8 +379,10 @@

 	/* maxfiles = pattlen^sufflen, but don't use libm. */
 	for (maxfiles = 1, i = 0; i < sufflen; i++)
-		if ((maxfiles *= pattlen) <= 0)
+		if (LONG_MAX / pattlen < maxfiles)
 			errx(EX_USAGE, "suffix is too long (max %ld)", i);
+		else
+			maxfiles *= pattlen;

 	if (fnum == maxfiles)
 		errx(EX_DATAERR, "too many files");


doveadm expunge -d: If mailbox is deleted, unsubscribe it also

--- src/doveadm/doveadm-mail-expunge.c
+++ src/doveadm/doveadm-mail-expunge.c
@@ -25,6 +25,7 @@
 	struct mailbox_transaction_context *trans;
 	struct mail *mail;
 	enum mail_error error;
+	int ret = 0;

 	if (doveadm_mail_iter_init(_ctx, info, search_args, 0, NULL,
 				   &trans, &iter) < 0)
@@ -38,28 +39,29 @@
 		mail_expunge(mail);
 	}

-	if (doveadm_mail_iter_deinit_keep_box(&iter, &box) < 0) {
-		mailbox_free(&box);
-		return -1;
-	}
-	if (mailbox_sync(box, 0) < 0) {
+	if (doveadm_mail_iter_deinit_keep_box(&iter, &box) < 0)
+		ret = -1;
+	else if (mailbox_sync(box, 0) < 0) {
 		doveadm_mail_failed_mailbox(_ctx, box);
-		mailbox_free(&box);
-		return -1;
-	}
-
-	if (ctx->delete_empty_mailbox) {
+		ret = -1;
+	}
+
+	if (ctx->delete_empty_mailbox && ret == 0) {
 		if (mailbox_delete_empty(box) < 0) {
 			(void)mailbox_get_last_error(box, &error);
 			if (error != MAIL_ERROR_EXISTS) {
 				doveadm_mail_failed_mailbox(_ctx, box);
-				mailbox_free(&box);
-				return -1;
+				ret = -1;
 			}
+		} else {
+			if (mailbox_set_subscribed(box, FALSE) < 0) {
+				doveadm_mail_failed_mailbox(_ctx, box);
+				ret = -1;
+			}
 		}
 	}
 	mailbox_free(&box);
-	return 0;
+	return ret;
 }

 static bool


allow polling for joseta data

allow polling for joseta data

--- examples/default-xbee/main.c
+++ examples/default-xbee/main.c
@@ -8,11 +8,18 @@
 #include "board_uart0.h"
 #include "radio_driver.h"
 #include "radio_trans.h"
-
+#include "radio_app.h"
 #include "xbee.h"
 #include "joseta.h"

+#define APP_PKT_BUFFER_SIZE 2048
 uint16_t mypan, myaddr;
+joseta_df_t joseta_last_minute[60];
+char abuf1[APP_PKT_BUFFER_SIZE], abuf2[APP_PKT_BUFFER_SIZE];
+bool joseta_fresh = false;
+
+char     *ja_names[] = {"occupan", "relay", "voltage", "current", "phase","tempera","timesta"};
+uint8_t   ja_types[] = {RA_FMT_u8, RA_FMT_u8, RA_FMT_u16, RA_FMT_u16, RA_FMT_u16, RA_FMT_u8, RA_FMT_u32};

 static int shell_readc(void){
     char c = 0;
@@ -53,30 +60,56 @@

 void j_callback(unsigned int type, joseta_df_t *buf, unsigned int num_records){
     if(type == JOSETA_CB_PURGE){
-        for(unsigned i = 0; i < num_records; i++)
+        /*for(unsigned i = 0; i < num_records; i++)
             printf("[joseta] time=%lu, voltage=%u, curent=%u, temp=%d\n",
                     (unsigned long) buf[i].time,
                     (unsigned) buf[i].voltage,
                     (unsigned) buf[i].current,
                     (unsigned) buf[i].temp
             );
+        */
+        printf("[joseta] purged %d records\n", num_records);
+        memcpy(joseta_last_minute, buf, sizeof(joseta_df_t) * num_records);
+        joseta_fresh = true;
     }
 }

 void incoming_packet(radio_trans_pkt* packet){
-    static char test[1002] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vitae ex eleifend, aliquam est ut, varius sapien. Nunc a vulputate diam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam efficitur, sapien vel fermentum fermentum, dolor diam aliquet erat, vitae rhoncus lorem arcu in risus. Donec id hendrerit nibh. Suspendisse sit amet lacinia purus, at gravida eros. Nam lobortis nunc vel ornare ultrices. Etiam suscipit odio a varius hendrerit. Vestibulum porta magna et suscipit vestibulum. Nullam dignissim nisi eget rutrum vulputate. Donec in risus quis metus rhoncus fermentum. Phasellus sodales magna non purus gravida tincidunt. Fusce et eleifend urna. Nunc convallis erat ac enim pellentesque egestas. Aenean vel volutpat tortor. Duis sagittis odio ultricies eros posuere, tristique efficitur turpis venenatis. Morbi condimentum imperdiet diam, vitae viverra ante pharetra id. Nunc consectetur mi id auctor ornare. Phasellus consectetur, sem sed sed.";
     switch(packet->hdr.type){
-        case RTRANS_TYPE_PROBE:
+        case RTRANS_TYPE_PROBE:{
             printf("[rt] incoming probe from %04x\n", packet->hdr.master);
             rt_set_master(packet->hdr.master);
             rt_transmit(RTRANS_TYPE_JOIN, 0, 0);
             break;
-        case RTRANS_TYPE_POLL:
+        }
+        case RTRANS_TYPE_POLL:{
             printf("[rt] incoming poll from %04x\n", packet->hdr.master);
-            rt_transmit(RTRANS_TYPE_DATA, test, 1001);
+            if(joseta_fresh){
+                void *next = abuf1;
+                uint32_t offset = 0;
+                int i;
+                for(i = 0; i < 60; i++){
+                    offset += app_append_sample(next + offset, APP_PKT_BUFFER_SIZE - offset, ja_types[0], joseta_last_minute[i].occupancy);
+                    offset += app_append_sample(next + offset, APP_PKT_BUFFER_SIZE - offset, ja_types[1], joseta_last_minute[i].relay);
+                    offset += app_append_sample(next + offset, APP_PKT_BUFFER_SIZE - offset, ja_types[2], joseta_last_minute[i].voltage);
+                    offset += app_append_sample(next + offset, APP_PKT_BUFFER_SIZE - offset, ja_types[3], joseta_last_minute[i].current);
+                    offset += app_append_sample(next + offset, APP_PKT_BUFFER_SIZE - offset, ja_types[4], joseta_last_minute[i].phase);
+                    offset += app_append_sample(next + offset, APP_PKT_BUFFER_SIZE - offset, ja_types[5], joseta_last_minute[i].temp);
+                    offset += app_append_sample(next + offset, APP_PKT_BUFFER_SIZE - offset, ja_types[6], joseta_last_minute[i].time);
+                }
+                uint16_t plen = app_build_pkt(abuf2, APP_PKT_BUFFER_SIZE, 60, 6, ja_names, (void *) abuf1, offset);
+                printf("[ra] constructed packet of size %u\n", plen);
+                rt_transmit(RTRANS_TYPE_DATA, abuf2, plen);
+                joseta_fresh = false;
+            }
+            else{
+                rt_transmit(RTRANS_TYPE_DATA, 0, 0);
+            }
             break;
-        default:
+        }
+        default:{
             printf("[rt] skipping incoming msg of type %02x\n", packet->hdr.type);
+        }
     }
 }


Fixed bug in beat averaging apply

Fixed bug in beat averaging apply

--- source/unemap/analysis_work_area.c
+++ source/unemap/analysis_work_area.c
@@ -1,7 +1,7 @@
 /*******************************************************************************
 FILE : analysis_work_area.c

-LAST MODIFIED : 9 March 2000
+LAST MODIFIED : 17 March 2000

 DESCRIPTION :
 ???DB.  Have yet to tie event objective and preprocessor into the event times
@@ -11311,7 +11311,7 @@
 static void trace_analysis_mode_apply(Widget widget,
 	XtPointer analysis_work_area,XtPointer call_data)
 /*******************************************************************************
-LAST MODIFIED : 9 March 2000
+LAST MODIFIED : 17 March 2000

 DESCRIPTION :
 Applies the current analysis mode settings to all signals.
@@ -11509,9 +11509,23 @@
 						}
 						(trace->area_3).edit.first_data -= start;
 						(trace->area_3).edit.last_data -= start;
+						if (divisions)
+						{
+							for (i=number_of_beats-2;i>=0;i--)
+							{
+								divisions[i] -= start;
+							}
+						}
 						start=0;
 						*(trace->event_detection.start_search_interval)=0;
 						*(trace->event_detection.end_search_interval)=end;
+						if (divisions)
+						{
+							for (i=number_of_beats-2;i>=0;i--)
+							{
+								divisions[i] -= start;
+							}
+						}
 						buffer->number_of_samples=end+1;
 						buffer->start=0;
 						buffer->end=end;
@@ -11572,7 +11586,6 @@
 									{
 										*beat_count=0;
 										beat_count++;
-										beat_counts[i]=0;
 									}
 									beat_end=start-1;
 									for (beat_number=1;beat_number<=number_of_beats;beat_number++)