You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/12/02 10:03:53 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #4894: libc/misc:add err.c to libc

xiaoxiang781216 commented on a change in pull request #4894:
URL: https://github.com/apache/incubator-nuttx/pull/4894#discussion_r760937037



##########
File path: include/err.h
##########
@@ -0,0 +1,133 @@
+/****************************************************************************
+ * include/err.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_ERR_H
+#define __INCLUDE_ERR_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdarg.h>
+#include <nuttx/compiler.h>
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/* Print "pid: ", FORMAT, ": ", the standard error string for errno,
+ *  and a newline, on stderr.
+ */
+
+static inline void vwarn(FAR const char *fmt, va_list ap)
+{
+  int error = errno;
+  struct va_format vaf;
+
+#ifdef va_copy
+  va_list copy;
+
+  va_copy(copy, ap);
+
+  vaf.fmt = fmt;
+  vaf.va  = &copy;
+#else
+  vaf.fmt = fmt;
+  vaf.va  = &ap;
+#endif
+
+#ifdef CONFIG_FILE_STREAM
+  fprintf(stderr, "%d: %pV: %s\n", getpid(), &vaf, strerror(error));
+#else
+  printf("%d: %pV: %s\n", getpid(), &vaf, strerror(error));

Review comment:
       dprintf




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org