Received: by 10.223.185.116 with SMTP id b49csp3648566wrg; Mon, 26 Feb 2018 03:46:25 -0800 (PST) X-Google-Smtp-Source: AH8x226o7dgK5GvAQ7THKs08jRst4JCVU1aCi0+BxEqUvbhPYc5N/ObI6hkiNjBk7yw2diVacEZU X-Received: by 2002:a17:902:bf0a:: with SMTP id bi10-v6mr10383300plb.181.1519645585359; Mon, 26 Feb 2018 03:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519645585; cv=none; d=google.com; s=arc-20160816; b=1EWkc6HXQFtdKFLXyMxm9bqNnhP4G97Wihx+9fjKsQ6Na9+FottwmCTxIuts0+Qbgh PPAvqxgDyDGTskFdG/hZ0dvguzC4U/yb0MYOj+exgcaccn5q1i+vKbxmukH4gkTcXJ8z V1bKn/VJciPBG6ScvNY5aLPLOMqIL7FR1EV2nCODewMHorFHkaOjw4H13JmLnvW+tISb XtrMxQJP6136O5DAwi93xwjZapS7IRtHmny3RwmhIGI+tZgRG9jsTI7uNhXPvKZewSKM gBmJZYNDaATj2rrdMivrOQqc1tbhJix9Y2j9JgGZI7H8QY2JVy1Ssjk0F53++3BwiFxz cAFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Tvz3CMgw6ZSOQAocDdk5jwt87F5a7JmTltar6WlwNM4=; b=gIfxF5uFy/8TqEmw38Z3aOdAua5nSYVgD8SxksiAFB17bw4N/eOUCvau40UiEnS7TF U5CoZ/eDLXlUtvIhv5drOv/rTjVRprihK6Og2Jexyfitw25GSDaoQKsRAREBWdQ9DgWa llxZwZ0SVRI73VnYVNpeD/IlblKCJ8BDT7uTLfrqpJluor67nMp1uSmX7ZyPal4gBsA/ JBUvZVd9K6R1S4/pERa9Xf0bx8YLRVhv+BjJZyzbFycgNRqdDWbq6t6ON57slrrTnvo2 Q7O17f9zFlvyrzwTYRk1M4BD599aZxpliTg96newkzQibi2wWRjsNKgcfqtXLYxxEnV7 eT8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=J8c3e6sq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si5440763pgv.672.2018.02.26.03.46.11; Mon, 26 Feb 2018 03:46:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=J8c3e6sq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752865AbeBZLor (ORCPT + 99 others); Mon, 26 Feb 2018 06:44:47 -0500 Received: from mail-qt0-f169.google.com ([209.85.216.169]:47050 "EHLO mail-qt0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752264AbeBZLoo (ORCPT ); Mon, 26 Feb 2018 06:44:44 -0500 Received: by mail-qt0-f169.google.com with SMTP id m13so13633022qtg.13 for ; Mon, 26 Feb 2018 03:44:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Tvz3CMgw6ZSOQAocDdk5jwt87F5a7JmTltar6WlwNM4=; b=J8c3e6sqq+35KSv+9Q7XcVOaGO0sDcp3GpkKDHmVX/vQrs5kG0jM98gWLePZMK3+LU J9m+V/eLKxqA6UmnSBEslLSxQ6/WqURGWzU5NPSYVm176w8BvgVaOpSeaoaY1CSN9zix JqjFJ9ZmMfjb3vdndiQrMIyAmcL78mvd5xNI7Fp9bIKbY6BMAg4p64okunV312vNS7n9 TmMUuSI1Zs22EGL+BQmYdPQ/c+3sjWczLzKluqCvDGni/5MP0vyGKV2O/oskg4ivhJ05 i+SriTIWRE+JctfmzpPHBbpJkgrugWRspSxCuKE09RZpp5/Sdouhv4t5red/Q3VBXM6u BXEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Tvz3CMgw6ZSOQAocDdk5jwt87F5a7JmTltar6WlwNM4=; b=RqU/OMHB6068AQtK+jRgK9izrqSXzh/0VChq9LTQyXG0AUMqOb6nYOsvCBBeNDLEGT yAPAskUppVi1svALYiPmBKn90QHDL3qte8KmP12V09DHSkvG5RyN22glO+LUWAATOxGR BmiPYmcTCNG+aVIcS6MM10RtMH0UICkwJ4ixklocOSZQB+6lxtjLFVjbq+4cqRgkrMqd efb/osPBAoAWYhGn8Nt0LMcGZdfShuRnvYYep8sNuMaWJWrI0VKMB3ADz5e/7djJXhc1 CpRmLU4AuNBCjLMNDDCLNoHhzU7Pvj9zakS+ZkPbpeyKoJdvOAQ7D8t0E3b6PNQ91kXc RrNQ== X-Gm-Message-State: APf1xPBmD1f2Pn6DMaoWOPfDxb58CTPkaVmC+FuO8kKBgo9hqOVcWckr uPLOLg2aDFEL0RRL7EtDZ7NsFYjRXKT04r0u/p0= X-Received: by 10.200.26.79 with SMTP id q15mr16487019qtk.174.1519645484213; Mon, 26 Feb 2018 03:44:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Mon, 26 Feb 2018 03:44:43 -0800 (PST) In-Reply-To: <20180225235432.31209-4-rabel@robertabel.eu> References: <9ec3c54c-f8fe-22d7-783e-8cf9862405bb@robertabel.eu> <20180225235432.31209-1-rabel@robertabel.eu> <20180225235432.31209-2-rabel@robertabel.eu> <20180225235432.31209-3-rabel@robertabel.eu> <20180225235432.31209-4-rabel@robertabel.eu> From: Andy Shevchenko Date: Mon, 26 Feb 2018 13:44:43 +0200 Message-ID: Subject: Re: [PATCH 3/4] auxdisplay: charlcd: fix x/y address commands To: Robert Abel Cc: linux-kernel , Miguel Ojeda , Willy Tarreau , Geert Uytterhoeven Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 26, 2018 at 1:54 AM, Robert Abel wrote: > NUL-terminate each individual number to be parsed. > To do this, the next command character and a pointer to its argument > are found and stored. The command character is then overwritten by NUL > before kstr* functions are called on the buffer. Can we avoid yoda style of programming? > case 'x': /* gotoxy : LxXXX[yYYY]; */ > + case 'y': { /* gotoxy : LyYYY[xXXX]; */ > + > + char* nxt_esc; > + char nxt_cmd; > + char cmd; > + struct charlcd_priv_addr tmp_addr; > + > if (!strchr(esc, ';')) > break; > > + /* sequence is processed whether legal or illegal */ > + processed = 1; > + > + /* copy current address to temporary buffer */ > + tmp_addr = priv->addr; > + > + nxt_cmd = *esc++; > + nxt_esc = esc; > + > + while ('\0' != *esc) { > + > + cmd = nxt_cmd; > + esc = nxt_esc; > + nxt_esc = strpbrk(esc, "xy;"); > + if (NULL != nxt_esc) { > + nxt_cmd = *nxt_esc; > + /* terminate current sequence with NUL */ > + *nxt_esc++ = '\0'; > + } > + > + if ('x' == cmd) { > + if (kstrtoul(esc, 10, &tmp_addr.x) < 0) > break; > + } else if ('y' == cmd) { > + if (kstrtoul(esc, 10, &tmp_addr.y) < 0) > break; Perhaps instead of dancing around kstrtox() better to switch to simple_strtoul() ? > } else { > + /* break on unknown command or ';' */ > break; > } > + > } > > + /* unknown commands in sequence will be followed by at least ';' */ > + if ('\0' != *esc) > + break; > + > + /* clamp new x/y coordinates */ > + if (tmp_addr.x >= lcd->width) > + tmp_addr.x = lcd->width - 1; > + tmp_addr.y %= lcd->height; > + > + priv->addr = tmp_addr; > charlcd_gotoxy(lcd); > break; > } > + } Same indentation level or my mailer hides this from me? -- With Best Regards, Andy Shevchenko